[英]jQuery UI: Resizable: catch the resize event
I have a div which is resizable and now I want to edit a cookie when this box is resized/when the user finished resizing. 我有一个可调整大小的div,现在我想在调整此框大小时/当用户完成调整大小时编辑cookie。 (I have the cookie plugin)
(我有cookie插件)
How can I do this? 我怎样才能做到这一点?
PS: I have multiple .div
's with different id's. PS:我有多个
.div
具有不同的ID。
<div class="div" id="div1"></div>
<div class="div" id="div2"></div>
My Code which doesn't work (it doesn't save the cookie) 我的代码不起作用(它不保存cookie)
$( ".div" ).resizable({
handles: \'s\',
onResize: function(size) {
$.cookie("div_height", this.height);
}
});
Use this code 使用此代码
$( ".div" ).resizable({
handles: \'s\',
stop: function(e,ui) {
$.cookie("div_height", ui.size.height);
}
});
Here is a working js fiddle to capture the resize event, having another example, but it perfectly suitable for you: http://jsfiddle.net/byrgv6j4/1/ 这是一个工作的js小提琴,用于捕获resize事件,还有另一个示例,但它非常适合您: http : //jsfiddle.net/byrgv6j4/1/
$('.resizable').resizable({
aspectRatio: true,
handles: 'ne, se, sw, nw',
resize: function(e, ui) {
//console.log(e);
//console.log(ui);
console.log(ui.size.height);
}
});
You must get the ui.size.height
if you want to get the height of the current state of the element. 如果要获取元素当前状态的高度,则必须获取
ui.size.height
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.