Multiple jQuery events in $(function () { ... only the first one works -


i have multiple .click() events page, first 1 executes expected.

$(function () {     $("#delete").click(function () {         $(this).hide();         $("span.hconf").show();     })     $("#div_conf_true").live("click", function () {         $.post("/u:" + $("span.username").text() + "/delete/"), {             url_id: $("#div_conf_true").attr("u"),             uname: $("span.username").text(),             complete: window.location.reload(true)         }     })     $("#div_conf_false").live("click", function () {         $("span.hconf").hide();         $("#delete").show();     }) }) 

originally #div_conf_* events .click(function (){ events, read dom changes unbind these handlers, tried .live, still didn't work. need in script make 3 click events accessible through dom changes?

i new jquery pardon if has obvious answer.


edit: neither second nor third .click() events work. have implemented syntax , indentation corrections suggested responders, still no change. code block above within script tag. need wrap block in else? issue $document.ready()? using .live() incorrectly? wrong method choice here? have no errors in chrome js console.

my main concern third .click() function should, understanding, reverse effect of first .click() function, operates expected. have pasted relevant html below.

<div id='modify'><a class='modify' id="edit" href='{{ edit_url }}'>edit</a> | <a class='modify' id="delete" u="{{ i.id }}" href='#'>delete</a><span class='hconf' style="display:none">are sure? <a class='confirm' id='del_conf_true' href='#'>yes</a> | <a class='confirm' id='del_conf_false' href='#'>no</a></span></div> 

edit2: have updated second .click() function, still no change in functionality.

$("#div_conf_true").live("click", function ( { $.post("/u:"+$("span.username").text()+"/delete/",          {             url_id:$("#div_conf_true").attr("u"),              uname:$("span.username").text()         },         function() {window.location.reload(true);}     );     }) 

$(function () {     $("#delete").click(function () {         $(this).hide();         $("span.hconf").show();     })     $("#div_conf_true").live("click", function () {         $.post("/u:" + $("span.username").text() + "/delete/"), { // <-. remove ) here             url_id: $("#div_conf_true").attr("u"),                //   |             uname: $("span.username").text(),                     //   |             complete: window.location.reload(true)                //   |         }                                                         // <-' , place here     })     $("#div_conf_false").live("click", function () {         $("span.hconf").hide();         $("#delete").show();     }) }) 

that line problem, remove ) after /delete/, otherwise you're closing out .post(). place after brace on highlighted line.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -