JQuery :: .click() Fires Callback More Than Once?
Sep 24, 2009
I've got a button toolbar, and users can select rows in a table. When they have selected some row's, they can click one of the buttons, and it invokes a callback. Problem is, when I click the first time, there's nothing wrong. But when I click the second time, it fires the callback two times, when I click the third time it fires the callback three times, and so on. That's a big problem, since the button is used to delete a page, and obviously it should delete it only once, since the AJAX would return an error ortherwise. The code is seperated in three blocks, first the the onclick on the button object, which invokes a function called confirmAction, taking to parameters. [1], a message for the users, [2] the name of the callback unction. When the confirmation is confirmed, the confirmAction function calls the callback. As said before, when I click #delete once, it behaves like expected. But when I click the second time (without refresh) it runs the callback function twice, third time thrice, and so on.
[code]
$('#delete').click(function() {
confirmAction('Weet je zeker dat je de geselecteerde pagina's wilt
verwijderen?', 'destroy');
});
[Code].....
View 2 Replies
ADVERTISEMENT
Oct 19, 2011
What I noticed is that my error callback is fired every time.
MyService.asmx:
[WebMethod]
public FileInfo[] GetFileInfo(int Id){
Proxies.ServiceRef.ServiceClient c = new Proxies.ServiceRef.ServiceClient();
return c.GetFileInfo(Id).ToArray();
}
The Jquery code where I am getting error:
$.ajax({
url: url,
data: jsonData,
type: "POST",
contentType: _I.contentType,
timeout: _I.timeout,
dataType: "serviceproxy", // custom type to avoid double parse
dataFilter: function (jsonString, type) { .....
When I debug using firebug the response is as follows.
{"d":[{"__type":"Proxies.AFARServiceRef.AssignmentInfo","ExtensionData":
{},"AssignDate":"/Date(1317748587667)
/","AssignFileName":null,"ClaimId":"PA026195","ClaimantName":"Rachel
Weiss","FirstContactDate":"/Date(1302678000000)/","FirstContactTime":{"Ticks":433800000000,"Days":0,"Hours":12,
"Milliseconds":0,"Minutes":3,"Seconds":0,
"TotalDays":0.50208333333333333,
"TotalHours":12.049999999999999,
"TotalMilliseconds":43380000,
"TotalMinutes":723,"TotalSeconds":43380},"Id":5257,
"InspectionDate":"/Date(1302246000000)/","StatusId":1,"SubmittedCount":5,
"UploadedCount":9}]}
View 1 Replies
View Related
Sep 30, 2011
JQuery click event fires on second click but not on first. I have had this happend before some time ago.
View 6 Replies
View Related
Mar 18, 2011
i generated a subnode for all unordered lists which are Childs of List-Elements like this:
<ul>
<li>1</li>
<li>2
<ul>
[Code].....
View 2 Replies
View Related
Apr 30, 2009
I add multiple items with each click and then I want to remove them one by one by clicking. All is ok, but if I add 2-3 items and the click the first one, confirmation alert fires multiple times when i click Cancel. The number of times depends on how many items goes after curent.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
[code]....
View 7 Replies
View Related
Jun 3, 2009
Firstly, I dont even know if this is possible but anyway I have a HTML form element problem, I want to be able to double click one item in a multi select box and I want that double click to fire of a modal popup box.
I am able to get a regular hyperlink to do the action for me but I need it to be an item in a multi select box.
I have uploaded an example of my problem here,[url].
so for example i would like a popup to appear when you double click "volvo" just like the popup appears for the hyperlink at the bottom.
View 4 Replies
View Related
Jan 8, 2010
I have the following code
Code:
$('a').live( 'click', doIt() ) ;
...
function doIt() { return false }
However, the 'return false' does nothing. If I click a link the event is not stopped and the page it points to is loaded!
So, what could I do, given the above code, to stop the click event ?
UPDATE: I inspected jQuery object and changed doIt to
Code:
function doIt() {
$.Event.preventDefault();
$.Event.stopPropogation() ;
}
Does not produce errors, but didn't stop the event, but I feel I'm getting closer
View 2 Replies
View Related
Aug 24, 2011
I create buttons from an array of objects that such as:
buttons = [{ text: "button 1", action: 1}, {text: "button 2", action: 2}];
I then loop thru the array to assign the text and bind the click event after having created the buttons with IDs of "button_<index>".
for( var index in buttons ) {
$("#button_"+index).html ( buttons[index].text )
.click( function() { clickButton( buttons[index].action ) } );
}
The text appears correctly in the button, but every button defined only fires the list bound click, in this example the action equal to'2'whether I push "Button 1" or "Button 2".My actual case has four buttons, all firing the event for the fourth button.I've tried not chaining the .click(), going thru the loop twice once for the .html and once for the .click, neither of which made a difference. If I hard code each button .click, it works fine.
View 2 Replies
View Related
Apr 13, 2010
I use the getJSON request to fill a select (with cities names) after the user have choosen his region.
I paste some code:
The problem is that callback is never called. I used firebug and i have seen that when i change region the getJSON function is called and my script (python) return this JSON:
Why my callback is not called? I can't even get the alert ('callback time!'). I thinked that my json could be broken, but firebug net console read and parse it very well, so i think is valid JSON.
I also tried to split up the function declaration from the getJSON request, but it's no use.
View 5 Replies
View Related
Sep 12, 2010
I have the following elements :
<input type="radio" name="alert_email" value="1"> Activé
<input type="radio" name="alert_email" value="0"> Désactivé
I have both elements in the following variable :inputElFrom that variable, I want to filter and get the element which has value "1", and trigger its click callback fct :
console.log(inputEl.length); // prints 2 (contains the two elements above)
inputEl.is('input[value=1]').trigger('click'); // error in Firebug "inputEl.is("
View 1 Replies
View Related
Sep 9, 2010
I have a series of checkboxes on a page and the goal is to run an ajax post each time one of the checkboxes is checked. When the page loads, the first time I click each of the checkboxes everything goes as planned. After I receive the response from my ajax php function and all related events fire, I click the checkbox again and nothing happens. The event listener seems to have stopped functioning.
Here is my code:
$(document).ready(function() {
$(':checkbox').change(function() {
$(this).attr('disabled','disabled');
$('#' + $(this).attr('id') + 'Waiting').addClass('loading');
[Code]....
View 6 Replies
View Related
Oct 11, 2010
I am having an issue with the dialog plugin. I have thelatestjquery and dialog version installed. I have a link that opens a form into a div and than I create a dialog with that div to display as a modal Iframe. It opens at the first time I fire the open event and it fires correctly the close event when I close the iframe, but when I try to open for the second time without refreshing the form that the dialog div is in it, it just does nothing. Do not create the dialog again nor display it to me if it is already created.
here is the code that fires up the dialog:
function addPedidoCliente() {
$.ajax({
url: server+"/ajax/Pedidos/addPedidoCliente",
data: "",
[Code]....
So every time I click on a specific button, this code is called, it is also performing the ajax request as I can see in firebug (the response is ok as well) but the dialog Iframe is not created.
View 1 Replies
View Related
May 16, 2011
I cant figure out why a trigger event fires in the following function:
But not in this function:
When using FF 4 or CHROME 10, it seems to work fine in IE9. I have validated that the second function is pulling the proper elements when selecting the toFire variable, but the trigger just doesnt seem to fire. Value is always true or false, never undefined and the Click event that is being fired in the second function is the same that is being triggered in the first function.
View 1 Replies
View Related
Jun 17, 2011
I'm busy experimenting with jquery at the moment for a website I'm trying to put together.
I have a bunch of links which fire a jquery function as follows:
<a href="#" class = "spam" onclick="return changeValue('1');">Spam</a>
<a href="#" class = "spam" onclick="return changeValue('2');">Spam</a>
<a href="#" class = "spam" onclick="return changeValue('3');">Spam</a>
[Code]...
View 2 Replies
View Related
Oct 4, 2011
I have this script:
<script
type
=
"text/javascript">
[code]....
But I don't know how to fire it (cause the dialog box to appear) using <input> to keep the button's styling in line with the rest of the page. This does not work:
<input class="loadButton" type="button" value="open dialog box" onclick="opener">
So how else do you fire the script?
View 1 Replies
View Related
Jul 30, 2009
I am trying to implement a div containing an advanced search form drop down on hover and I have everything working (only in FF) except for when I try to add any sort of animation or speed to the '.show' or'.hide' effect. When I try to add speed or seemingly any other effect to the div, the select elements of the search form fires the hover
[Code]...
View 1 Replies
View Related
Oct 18, 2011
I have a problem when I use the .live() function that I can't figure out. It's something I've run across several times and it keeps confusing me.
My jQuery:
jQuery('#content div.portfolio').live({
mouseover: function(){
jQuery(this).find('img').fadeOut();
[code]....
My problem is: when the mouse enters and leaves the image the image fades in and out for up to four times. The first mouseenter is just fadeout, fadein, fadeout. why is the event being triggered multiple times and more importantly what can I do to prevent this behavior?
View 8 Replies
View Related
Dec 14, 2010
I have a problem with load(), which I cannot find on forum search or google. I have a container "right_col" that should be filled with jQuery after clicking on any hyperlink. The result shall be a HTML page that only changes the content area. On the first loading of the page it works as intended. But after the first load() no more jQuery is used and the page changes URL in Browser and reloads the entire page. After this reload you have again one jQuery that is working and so on.
HTML Code:
<div id="right_col">
<div id="right_content">
</div></div>
This is my JS code:
$(document).ready(function(){
var fadeTime = 200;
$("#right_col").css("display", "none");
$("#right_col").fadeIn(fadeTime);
// links
$("a").click(function(event){
event.preventDefault();
linkLocation = this.href;
$("#right_col").fadeOut(fadeTime, contentloader);
});
function contentloader() {
$('#right_col').load(linkLocation + ' #right_content',null, function(){
$("#right_col").fadeIn(fadeTime);
});}});
As you can see, I'm loading the whole linkLocation and want to replace the content within #right_col with all HTML of #right_content including this div aswell.
I tried Firebug to fugure out if i have more than one #right_col after the load().
I tried replacing IDs with classes to prevent element doubling.
I tried to remove the #right_content param and pass a variable to my script to only print the needed HTML.
Nothing works.
And the Fun part: I also have a menu outside of #right_col. Calls from there on are working perfectly as intended.
View 1 Replies
View Related
Sep 1, 2010
I have a series of 6 checkboxes with the same name. The purpose is that whenever one of these is checked or unchecked, another part of the page is filled again based on an AJAX query, that has the values of all the checked checkboxes as input.
I added an onchange event handler like this: $('[name!=stage]').change(refillActionsParameters); what happens is that this handler function gets called 6 times when I check or uncheck any of the checkboxes. As a remedy, I put the onchange handler on the form that contains the checkboxes, but that didn't help, still 6 times.
Also: is there a quick way to retrieve the values or the ids of the checked boxes?
View 4 Replies
View Related
Aug 25, 2011
I am using window.unload for some use case in my code. But windows.unload fires on every event. I know to controller it on event like button click or link, but how do I prevent Unload event to fire on refresh or back button event?
View 4 Replies
View Related
May 30, 2011
I have a problem where the page doesn't expand when more results get loaded via jquery on a facebook style wall. Once more results get loaded the footer stays static instead of moving down.
What's the best way to do this?
View 7 Replies
View Related
Nov 12, 2010
i have a FAQ Question h2 acting as a trigger to slide out a hidden div below it, the FAQ answer, and clicking it toggles the h2 class so the bg img changes.toggle_container is the hidden div, h2 is the trigger..
code below:
$(document).ready(function(){
$(".toggle_container").hide(); // Hides the container onLoad
$("h2.trigger").click(function(){
[code]....
now i have a rating plugin that sits in the h2 tag. when i click the rating star, it behaves as intended, but also then somehow calls the above code and expands the FAQ answer.
View 3 Replies
View Related
Apr 14, 2010
i've a problem using the change-handler in a simple html-formular. the change-handler fires twice when the input-field already defines an onChange-Event.
Example: in head of html:
<script src="jquery-1.4.2.js" language="javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#abc").change(function(event){event.srcElement.style.borderColor='red';
});});
[Code]...
View 1 Replies
View Related
Jan 5, 2010
So, there's a main column of content and to the left of the main column is an A element that is absolutely positioned.I have an announcement system that when there's an active announcement, a box is rendered above the main column, pushing the main column down. However, the A element that is absolutely positioned stays where it is.I added code to check for an active announcement and add a class to the A element so it'll keep it positioned alongside the left-border of the main column.When a user closes the announcement box, it fades out, and the maincolumn moves back up to fill the space - but the positioned A element does not follow. I then added code to the function I had to fade out the box and save a cookie to show the user had closed the active announcement box which removed the active-announcement class I had PHP add to the A element.
The problem is, even though the removeClass function is last in the series of functions, it fires first - the positioned A element moves up to where it should be BEFORE the active announcement box fades out.How can I change this so that the positioned A element has its class removed after the other two things have taken place?[code]
View 2 Replies
View Related
Jan 4, 2012
I am wanting to avoid loading a seperate instance of jQuery in each of many iframes. For the most part this is working well. The problem I'm having is with the ready event. It does not seem to work properly withina child iframe. parent.$(document).ready(function () { /* this fires before the DOM is ready.*/ });
Based onwhat I have read I am guessing it is firing immediatelywhen called ratherthan waiting for the DOMto beproperly loaded first. I can getwindow.onload to work, but it fires late in the game. Is it possible to get a proper 'ready' event triggered within an iframe without loading a seperate instance of jQuery ?
View 7 Replies
View Related
Feb 1, 2010
I am using JQuery 1.4.1. I have HTML input elements which created dynamically. I have assigned "focusin" event all input elements. While loading page, it is triggers only once while focusing each input element. When I minimize and maximize the page, focus event is fired multiple times. Finally it show "Stack overflow at line 0".
$('input').live("focusin",function(objectRef) {
alert("focusin event");
})
View 1 Replies
View Related