开发者

Reset functions after ajax

I have this javascript file开发者_运维技巧: http://pastebin.com/m2keHsTM

A big part of it is a toggle switch that works by sliding your finger or mouse on it. As you see at the end of the document

var togglebox = "<div class='toggle_box'></div>";
    $('input[type=checkbox]').css('display','none');
    $('fieldset[data-input-type=checkbox]').append(togglebox);
    var mouseDown = false;
    var beginTouchDown = 0;
    create_elements();
    set_listeners();

replaces the checkboxes on the page by div's that are "slideable" This works great, only when I load another page trough ajax, other new checkboxes do not get replaced. Is there a way to reset those functions and make them check again after an ajax call?

Thanks a lot for your help :)


You can:

  1. Call set_listeners also after the load function call: http://api.jquery.com/load
  2. Change set_listeners to bind to events with live instead of bind or mouse... event binders: http://api.jquery.com/live


I just added the original functions to hijacklinks() to initiate them each time the page changes :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜