开发者

The events go out after ajax update

I have wr开发者_JAVA百科ited à checking/unchecking input code that works well in the fisrt loading of the page, but since I add an input via ajax then reload the inputs with the new input, the checking/unchecking event no longer works, I wonder what's the problem.

thanks before


That's the xhtml markup:

<div style="display: block;" id="regionLocalList">
    <div class="itemRegionCountry">
      <input type="checkbox" checked="checked" value="1" name="auteur[]" id="aucun">
      <label for="tous">no actor</label>
    </div>
    <div class="itemRegionCountry">
      <input type="checkbox" value="3" name="auteur[]" id="3">
      <label>others</label>
    </div>
    <div class="itemRegionCountry">
      <input type="checkbox" value="510" name="auteur[]" id="510">
    <label for=" Nick">Nick</label>
    </div>
    <div class="itemRegionCountry">
      <input type="checkbox" value="509" name="auteur[]" id="509">
      <label for="Craver">Craver</label>
    </div>
</div>

That's the check/uncheck jQuery code

var othercheckboxes = $("#regionLocalList .itemRegionCountry input:not(#aucun)");
var aucun = $("#aucun");
$("#regionLocalInput").click(function(event) {
$("#regionLocalList").toggle();
                                            })
$(aucun).click(function(event) {
$(aucun).attr('checked',true);
$(othercheckboxes).attr('checked',false);
                                 });
$(othercheckboxes).click(function(event) {
                if (this.checked){
                $(aucun).attr('checked',false);
                                 }
$(othercheckboxes).each(function (i) {
            if ($(this).is(':checked')) {
            $(aucun).attr('checked',false);
            return false;
            }
            else 
            {
            return $(aucun).attr('checked',true);
            }
    });
});

After adding the new input via a jQuery UI dialog, I retrieve the same xhtml above with a new input, after that I update the #regionLocalList div with html returned with ajax:

$("#regionLocalList").replaceWith(html);

The new input appeared but the event doesn't work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜