jQuery how to translate livequery to on?

本秂侑毒 提交于 2019-12-08 06:11:47

问题


I have this code which works however it is using a old legacy function "livequery" which should really be switched to using "on". However for the life of me I can't get this to work. Here is my code snippet.

jQuery('.box').livequery(function(){
     jQuery('a', this).click(function() {
          return false;
     });
     jQuery(this).draggable({
        appendTo: "body",
        helper: 'clone',
        opacity: 0.5,
        zIndex: 900,
        stop: function(event, ui) {
        return true;
        }           
     });
});

And I tried this...

jQuery('.box').on('draggable', function(){
     jQuery('a', this).click(function() {
          return false;
     });
     jQuery(this).draggable({
        appendTo: "body",
        helper: 'clone',
        opacity: 0.5,
        zIndex: 900,
        stop: function(event, ui) {
        return true;
        }           
     });
});

That didn't work as I am guessing "draggable" isn't the event name...

Thanks..


回答1:


This answer over there New Inserted dom node may help you to convert your code into on functionality instead of live function



来源:https://stackoverflow.com/questions/12332482/jquery-how-to-translate-livequery-to-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!