如何从另一个事件触发jquery调整大小
How to trigger jquery resizable from another event
我有一个可调整大小的窗口:
$(".question-case-story").resizable(
{ handles:{'s': handle },
alsoResize: ".question-case-inner",
//minHeight: #,
//maxHeight: #,
maxHeight: $(".question-case-story").height(),
resize: function (event, $this) { $(this).css({left:'inherit', top:'inherit'}); }
});
当我点击按钮在其他地方做一些事情时,我想让这个调整大小自动发生,但是到一个特定的高度(窗口高度)。我该怎么做呢?
我发现了一个类似的问题,但它没有解决如何设置任何细节:如何触发jquery Resizable resize编程?
这里也是一样:http://forum.jquery.com/topic/triggering-resize-event-set-by-resizable
我运行jQuery UI v. 1.9.2
更新:我不能只是"设置"新的高度($(thing).css('height', whatever)
),因为有其他的东西在div内部与可调整大小的功能交互
应该可以了:
var manresize=false;//Variable declared in a global scope
$('#buttonid').click(function(){
manresize=true;
$(".question-case-story").trigger('resize');
});
现在需要创建一个自定义事件,例如manualresize
。
然后将该事件的监听器附加到$(".question-case-story")
对象
$(".question-case-story").bind('manualresize',function(){
//Same code that would run in the .resizable()
//method with a resize event trigger
});
复制/使用resize
事件调用的.resizable()
小部件的代码(不是100%确定这一点,但我认为jQuery可悲地不使用prototype
)在您的自定义事件
在你的$(".question-case-story")
对象:
resize: function (event, $this) {
$(this).css({left:'inherit', top:'inherit'});
if(manresize/*var set on manual trigger*/){$(this).trigger("manualresize");manresize=false;}
}
如果我理解正确,你只是想元素的大小调整,然后尝试:
$('#button').on('click', function(){
$('.question-case-story').width(somevalue);
$('.question-case-story').height($(window).height());
}
相关文章:
- jQuery调整大小函数只适用于窗口
- 使用jquery调整文本区域的高度
- jQuery调整大小和视口检查点
- 使用jquery调整表格布局/结构
- Jquery调整大小动态更新
- jquery调整大小函数没有'不起作用
- jquery调整大小为移动窗口iPhone / Android
- 使用 jQuery 调整宽度,使 p 元素高 4 行
- jQuery 调整大小和滚动
- 如何使用 jquery 调整超链接图像的大小
- jQuery调整大小函数的问题
- XSS 攻击漏洞 - 使用 JavaScript 或 jQuery 调整查询
- IE8 问题 - jQuery 调整页面大小时导航 html
- jquery调整大小函数没有按照我期望的方式工作
- Jquery 调整 li 大小以适合 ul
- 选择,然后使用jQuery调整具有一定比例的图像大小
- 如何使用js或jquery调整非子图像的大小
- Jquery 调整具有心跳效果的图像大小
- 使用 jQuery 调整图像高度
- 为什么jquery调整大小不起作用