jQuery如何将livequery转换为on? [英] jQuery how to translate livequery to on?

查看:99
本文介绍了jQuery如何将livequery转换为on?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码可以正常工作,但是它使用的是旧的遗留函数"livequery",实际上应该切换为"on".但是对于我的一生,我无法使它正常工作. 这是我的代码段.

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;
        }           
     });
});

我尝试了这个...

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...

谢谢..

推荐答案

在那的答案

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

这篇关于jQuery如何将livequery转换为on?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆