2012-02-18 55 views
0

我有以下一段代码。 查看关于该问题的两条评论。为什么如果我修改其范围之外的变量,JQuery UI排序不会丢失?

$(settings.columns).sortable({ 
    ... 
    ... 
    start: function(e, ui) { 
    ... 
    stickies.block = true; // This line is OK 
    }, 
    stop: function(e, ui) { 
    ... 
    stickies.block = false; // Without this line it works, with it I can't drop the widget 
    } 
}); 

由不能放下,我的意思是我可以捡起来很好,但放开鼠标按钮不起作用,我仍然拿着小部件。 有什么建议吗?

+1

如果您可以在http://jsfiddle.net/上重现此问题,这将有所帮助 – Shad 2012-02-19 00:30:43

回答

0

对不起,我解决了。由于CoffeeScript使语句的最后一行返回,所以我有这个错误,所以我意外地返回false。

$(settings.columns).sortable({ 
    ... 
    ... 
    start: function(e, ui) { 
    ... 
    return stickies.block = true; // This line is OK 
    }, 
    stop: function(e, ui) { 
    ... 
    return stickies.block = false; // Without this line it works, with it I can't drop the widget 
    } 
}); 

当然,返回false会取消事件并阻止它放弃注释。

相关问题