Hi Wizzud You provide to me the best explain how click() and events works and how unbind() them. Should be in documentation.
Thanks a lot "2. the click functions You detail the click function attached to div.vote_against_selected, the last steps of which are to change the class of the clicked element to be div.vote_for_selected. Not a problem in itself. However, say that, when you run the code that assigns the div.vote_against_selected click function, it picks up Element A. Element A, when clicked, will now run the function you have specified below. As a result of running that function Element A will have its class changed. BUT that will not affect the code that runs the next time you click Element A! It will still run the function you have specified below because that is the code that was assigned to its click. The only way (outside of the behaviours plugin?) to get Element A (now with class vote_for_selected) to run the other code you now want it to run when clicked, is to remove (unbind) Element A's current click function (the stuff below) and to assign (bind) a new click function with other the code." Regards Mario Moura 2007/7/30, oliver <[EMAIL PROTECTED]>: > > > It sounds to me as though you are setting up the $ > ("div.vote_for_selected").click( ... ) event when the div in question > does not actually have that class, correct? If so, it is not going to > work. Setting an event on a jQuery selector that returns no DOM > elements does NOT set up events for when those elements do eventually > exist: it just fails silently. > > What you want to do is have the two click functions attached to the > same DOM element, so I would just put them in the same function body > with an if/else statement to figure out what the current class is and > thus which branch of the code to run. > > oliver > > On Jul 28, 8:50 am, inVINCable <[EMAIL PROTECTED]> wrote: > > Hello everyone, > > > > I am just about ready to throw my darn computer out the window > > here :P. > > > > What I am doing is quite simple, I am using the .load() function to > > call upon a function, like so: > > > > $("div.vote_against_selected").click(function(){ > > //first load content > > $("div.fake").load("/stories/vote/1/" + $storyid); > > > > )}; > > > > I should note that div.fake does NOT exist, as I do not want anything > > loaded, because I change the div myself, via the .html() function, > > like so: > > > > $first_new_votes_for = $votes_for * 1 + 1; > > $first_new_votes_against = $votes_against * 1 - 1; > > if ($first_new_votes_against == "") { > > $first_new_votes_against = "0"; > > > > } > > > > $("h3.votenumberfor").html($first_new_votes_against); > > $("h3.votenumberagainst").html($first_new_votes_for); > > > > That works fine and dandy as well! Now, at the very end of my .click() > > function, after the load, and the .html() functions have taken place, > > I remove and add a class like so: > > > > $(this).removeClass("vote_against_selected"); > > $(this).addClass("vote_for_selected"); > > > > Again, this works perfect! I even look at look at the code with > > firebug, and the classes are removed, and added, which is what is > > exactly what is supposed to happen. But here is the kicker, I have > > another function that does the EXACT same thing, but is for the > > vote_for_selected. You will notice right above I used the addClass on > > the vote_for_select above, like this: > > > > $(this).addClass("vote_for_selected"); > > > > Again, after looking at the source and verifying that the change was > > made, I try clicking on the new class (that was changed from > > vote_against_selected, to vote_for_selected when a click on > > vote_against_selected took place) but NOTHING happens! Ah, and I > > cannot understand why because looking at my source, the class is > > changed, so why isn't jquery recognizing this change! > > > > Any tips/pointers/advice on where to go from here or any functions to > > look at are greatly appreciated! (Btw I have use the bind() function > > in every possible combination but nothing seems to work :( > > > > Sincerely, > > Vince > > -- Mário Alberto Chaves Moura [EMAIL PROTECTED] 31-9157-6000