Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have my own page where I load an external third-party JavaScript that analyzes my DOM. The problem I am facing is as follows. I install some event listeners ('keypress', 'input', 'click') but after I append mentioned script (and she performs some computation), some of my listeners are not working any more. To be precise, 'click' listener is intercepting click events as expected, but other two are not intercepting anything. Is there a way for that external script to interfere with my listeners?
Btw., I am setting useCapture to true when installing my listeners, like this:
document.addEventListener('input', function...., true);
...
I don't have any other code to provide you with.
P.S. I am not able to play with the external code since it is obfuscated.
P.P.S. Installing the handlers again did not help.
It is possible, although quite unlikely, that the third-party code is capturing the event(s) before and and stopping it propagating (e.stopPropagation()). This would require the code attaching a listener to the same event on a parent element in the capturing phase.
Without more code to see, particularly this third-party code, it's hard to find the actual problem.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm testing some javascript on jsfiddle and for some reason I can't get a function to fire on a button click. Any advice?
jsfiddle link
In the Frameworks & Extensions panel, set onLoad to No wrap - in <body>.
It took me a while to figure this out.
You have configured JSFiddle to wrap the code in an onload event handler. Consequently the function you are trying to call onclick is out of scope.
Don't use intrinsic event attributes. Use jQuery's (since you are using jQuery already) event binding instead.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I add my TRIGGER DIV A over $(".DIVB").html(data); from a AJAx Responsebut when i now want to trigger some code over the $(".TRIGGER DIV A").click(function() it isnt working. Can someone explain me why ? And is there a Way to fix this or is there a working arround ?
It looks like you're using jQuery's .click(). If HTML is added dynamically to the DOM, you need to bind the click event to the element after it has been added. Otherwise, when $(".TRIGGER DIV A").click(handler) runs and jQuery looks for the element to bind, it isn't able to find it.
You may consider using .delegate() instead. This ensures that the event is bound to all elements relevant to the given selector regardless of when it is added to the DOM. You can find the documentation for usage here: http://api.jquery.com/delegate/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Suppose an application has a chat module containing messages. There is a jQuery click handler on said chat module that fires a series of focus related events whenever it detects a click.
Now suppose that when certain messages within the chat module are clicked, the event never bubbles up and a click event is never activated on the chat module.
How would I troubleshoot such an issue? I have a theory that somewhere in the application an intermediate element between the message click handler and the chat module click handler which is capturing the event and calling e.stopPropagation on it. There is currently no tools in Chrome to trace event propagation though.
What is the best way to trace event propagation in Chrome?
Override jQuery.Event.prototype.stopPropagation with a function containing a debugger statement:
jQuery.Event.prototype.stopPropagation = function() {
debugger;
};
From there perform the user actions that will fire the stopPropagation event; this time however a the debugger statement will cause the JavaScript to pause execution and you can observe the stack trace to see where it is being called from.
Put an ever-loving crap-ton of console logs everywhere. Not the most elegant solution, but it allows me to see what information is getting passed and where any and all hiccups are.
console.log(var);
I may suggest you to open the Chrome console (F12) go to elements, select the element of your interest and with right mouse click set the subtree modification.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
So, i am in the midst of making a little website where you can calculate right angled triangles. Y'know, just for the fun of it.
Atm, i'm testing the real time calculation of the different html forms, however, i can't figure out why the form for cathetusB isn't updating.
Any help is appreciated!
This is how all the forms are set up: <input type="number" step="0.01" id="someID" onkeyup=calculate();>
The JS code messed up when i tried to paste it in, so here's a fiddle!
EDIT: Added all the code to the Fiddle!
You have configured JSFiddle so that the code runs in an onload event handler.
The functions are therefore scoped to that handler function.
They are not globals.
They are not accessible to your intrinsic event handlers.
Configure JSFiddle to place the JS in the body instead of onload and the code works.
It would be better to replace your intrinsic event handler attributes with programatic event binding.
Be careful when using this :
<input type="number" step="0.01" id="cathetusA" onkeyup=calculate();>
If you are using the same id with every form things your code will not work.
Id must be unique for every object
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I've created an eBay listing and it work's correctly on eBay.
But I have an issue. The listing's are listed via 3rd party software and that software has their own JS for changing the images. And it doesn't work with my scripts. I use jQuery.
Can anyone advice a simple method to swap the image src on click event?
For example: Leave as it is, but overwrite the JS. Now it is set up to listen for mouse hover. Can I write a new script so when clicked it would swap the images?
Here is the link to the listing: Listing template here
To change src attribute of an image :
$('#myImage').click(function(){
$(this).attr('src', 'myNewImage.jpg');
});
To stop listening to the mouseover event :
$('#myTargetWhichHasAnEventAttached').off('mouseover');
Edit to answer the comment :
$('.image_small_js').off('mouseover'); // supposed that the mouseover event is attached on .image_small_js
$('.image_small_js').click(function(){
$('#bigpicture').attr('src', $(this).attr('src')).hide().show(); // .hide().show() makes the change effect more smoothy... can be used with timers
});