gpt4 book ai didi

jquery - 初始化后无法应用 JqueryUI 可调整 AspectRatio?

转载 作者:行者123 更新时间:2023-12-03 22:21:02 24 4
gpt4 key购买 nike

我试图在 JQueryUI 可调整大小中动态打开/关闭纵横比,但是即使将选项设置为 false 后,它仍然保持纵横比。以下是我当前正在使用的代码:

$('#aspect_check').click( function() {
var ischecked = $('#aspect_check').prop('checked');
if (ischecked) {
$( "#resizable" ).resizable( "option", "aspectRatio", .75);
} else {
$( "#resizable" ).resizable( "option", "aspectRatio", false );
}
});

我发现了一份 3 年前的错误报告,尽管将其标记为严重,但看起来它仍然没有得到修复。 http://bugs.jqueryui.com/ticket/4186

这些解决方法不适用于最新版本。有什么想法吗?

编辑:在查看了大量错误报告后,这里有一个解决方法:

$(function() {
$.extend($.ui.resizable.prototype, (function (orig) {
return {
_mouseStart: function (event) {
this._aspectRatio = !!(this.options.aspectRatio);
return(orig.call(this, event));
}
};
})($.ui.resizable.prototype["_mouseStart"]));
});

将其粘贴到您的 javascript 脚本部分。希望它可以帮助有类似问题的人!

最佳答案

这对我有用,无需修补

$('#resizable')
.resizable('option', 'aspectRatio', false)
.data('uiResizable')._aspectRatio = false;

这部分.data('uiResizable')._aspectRatio = false;来救援

关于jquery - 初始化后无法应用 JqueryUI 可调整 AspectRatio?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8133565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com