如果我有这个权利,你想什么在页面上有“固定”类可调整大小,即使该类是在页面加载后添加?你是对的,生活,绑定和委托在这里没有帮助。
我能想到的两种可能性,也不可爱。
首先,成立了现场“的mouseenter”事件,这将使该元素可以调整大小,如果它以前是不可能:
$(body).delegate(".fixed", "mouseenter", function(ev) {
var target = $(ev.target);
if (target.data("resizable")) return;
target.resizable({
aspectRatio: true,
handles: 'all'
});
})
这让我们动轮没有事件绑定到的问题。
或者,你可以猴补丁jQuery.fn.addClass:
var classRe = new RegExp(c + className + \b);
._addClass = jQuery.fn.addClass;
jQuery.fn.addClass = function(className) {
if (classRe.test(classname)) {
if (this.data("resizable")) return;
this.resizable({
aspectRatio: true,
handles: 'all'
});
}
jQuery.fn._addClass.apply(this, arguments);
}
当然,如果类是通过addClass方法添加这只会工作。
在你的榜样
此外,
$('lyr').addClass('fixed');
也许应该是:
$('.lyr').addClass('fixed');
我用的liveQuery插件-http:过去//brandonaaron.net/code/livequery/docs能够针对添加到DOM元素,像你的情况。 – motoxer4533
谢谢,把它作为答案,我会接受。 – digout