I'm trying to access the event.toElement property when the beforedeactivate event occurs, but it is returning undefined under IE9. It seems to work under IE8. The code below is an example of what I am trying to do:
$('#myButton').bind('beforedeactivate', myHandler);
function myHandler(event)
{
var target = event.originalEvent.toElement;
}
Can't seem to find much information on this issue so I was wondering if someone can explain why this is happening or suggest a workaround for the problem?
Related
https://codepen.io/mdaw11/pen/rNMbdqd
Created this little issue tracker for public use, works fine in Codepen, however once I try to open it in Chrome browser, the console outputs error
'Uncaught TypeError: Cannot read property 'length' of null
at fetchIssues (main.js:71)
at onload ((index):10)'
This tells me that there is something wrong with my fetchIssues(); perhaps var issues = JSON.parse(localStorage.getItem('issues')); isn't outputting what I expect it to be?
Any help would be much appreciated!
Could be fetchIssues() is being executed too early and could also happen if you don't have anything saved to the localStorage yet. Also double check what localStorage.getItem('issues') returns.
To fix that error you could try something like:
var issues = JSON.parse(localStorage.getItem('issues') || '[]');
I need to use onceEventListener method from an instance of H.Map as documented here, but instead it threw me an error saying that Uncaught TypeError: map.onceEventListener is not a function. What could be wrong?
Fiddle here.
Seems to be a bug in the API, try using addEventListner and removeEvent Listner as a work around
map.addEventListener('tap', event1, false);
var event1=function (evt) {
console.log("executing listner 1");
map.removeEventListener('tap', event1);
}
This does indeed seem to be a bug with our APIs. For now, the work around is a good idea, and I have notified the MAPJS team so they can look into the issue. Thanks.
So I've stumbled upon this a several times and now I'm finally fed up with this topic. Searching and googleing about it confuses me every time and now I'll need to ask by myself here.
I'm up to implement native HTML5 drag&drop in a web app. It works fine in Chrome and in IE too (at least when I tried last time).
The problem now is, that event binding via jQuery wont work out properly in Firefox, whereas it does so in Chrome! This is my Code:
$(document).on('dragstart','.leistung', function(){
cedamed.handlers.dragElement(event);
});
And this is my handler:
this.dragElement = function(event){
var dataObj = {};
dataObj.category = event.target.getAttribute('class');
dataObj.description = event.target.getAttribute('description');
dataObj.code0 = event.target.getAttribute('code0');
dataObj.code1 = event.target.getAttribute('code1');
dataObj.code2 = event.target.getAttribute('code2');
event.dataTransfer.setData('Text',JSON.stringify(dataObj));
console.log("dragging");
};
Works in Chrome, Firefox gives me the following error:
ReferenceError: event is not defined
It points to the line with:
cedamed.handlers.dragElement(event);
I have come across 'solutions' that involved the originalEvent-property of the event api, which is often supposed to make everything work fine in FF, but it does not at all in my case. I made it work by setting the 'ondragstart'-attribute directly in the HTML, but shouldnt it work with 'jQuery.on'?
I'm sorry, there are several questions to this topic out there, but I just dont get whats going wrong in this field. Can you please give me an insight, whats wrong in here?
I found out I have to pass 'event' as an argument to the jQuery callback function in 'on' such as:
$(document).on('dragstart','.leistung', function(event){
cedamed.handlers.dragElement(event);
});
With usage of originalEvent in 'drageElement' I made it work finally. Sorry...
I've created a Javacript Library called Tocl. I've tested it in Chrome and Safari and everythigs work properly. But when I test it on Mozilla browser (Firefox, Aurora) nothing happen here. I don't know whats going on here. The console says 'Tocl is undefined' and 'ToclObject' is not constructor. But on Chrome and Safari everythings is ok. Can you help find out whats wrong in my code?
This is my repository:
https://github.com/mahdaen/tocl
https://github.com/mahdaen/tocl/tree/master/sample
Thanks.
I managed to isolate the problem:
window.ToclObject = { bug : 'bug fixed'};
Object.defineProperty(window, 'ToclObject', {});
console.log(window.ToclObject.bug); // error
I also added a fix:
window.ToclObject = { bug : 'bug fixed'};
Object.defineProperty(window, 'ToclObject', { value : window.ToclObject });
console.log(window.ToclObject.bug); // bug fixed
The problem is found here: tocl.base.js:1260
PS: If you're interested in how i isolated it:
I copied your code to a file that shows the problem and removed (deleted) code until the error wouldn't show. Then i backtracked to see what exactly i removed between the error showing and not showing and tada... that's where the problem was.
I'm working on a d3 and js project.
The beginning of the function looks like:
$(document).ready(function() {
d3.select("#aid").select(".abutton").on("mousemove",function() {
afile.style("top", (event.clientY+10)+"px").style("left",(event.clientX+15)+"px");
afile.html("<h3>Click text here</p><p>or here</p>");
});
I've done quite a bit of Googling!
The essence is that on mouseover, it should do the function. This works in Chrome and IE because the event variable is global, and as such so are it's client* properties.
The solution, as I understand it, is to pass in an eventObject. When I do that, my code looks like:
$(document).ready(function() {
d3.select("#aid").select(".abutton").on("mousemove",function(event) {
afile.style("top", (event.clientY+10)+"px").style("left",(event.clientX+15)+"px");
afile.html("<h3>Click text here</p><p>or here</p>");
});
The Firefox log gives me:
[09:59:04.308] TypeError: event is undefined # filepathofjavascriptfile
and similarly, it breaks in Chrome:
Uncaught TypeError: Cannot read property 'clientY' of undefined filepathofjavascriptfile
(anonymous function) help.js:34
What am I doing wrong? Please let me know if you need anything else.
Try:
d3.select("#aid").select(".abutton").on("mousemove",function() {
afile.style("top", (d3.event.clientY+10)+"px").style("left",(d3.event.clientX+15)+"px");
afile.html("<h3>Click text here</p><p>or here</p>");
});
For whatever reason, that's how d3 exposes the event object.