是否可以在 jQuery UI 的 Dialog?
Is it possible to add containment (confining to the boundary of another element) to jQuery UI's Dialog?
您可以定位对话框并对其应用包含.试试这个:
You could target the dialog box and apply a containment to it. Try this:
var container = $('.dialog-container'),
dialog = $('.ui-dialog');
// get container top left corner locations
var cx1 = container.offset().left,
cy1 = container.offset().top;
// get dialog size
var dw = dialog.outerWidth(),
dh = dialog.outerHeight();
// get container bottom right location, then subtract the dialog size
var cx2 = container.width() + cx1 - dw,
cy2 = container.height() + cy1 - dh;
dialog.draggable( "option", "containment", [cx1, cy1, cx2, cy2] );
我为您设置了 一个演示.
Edit2:更改为使用对话框外宽度 &外部高度
I set up a demo for you.
Changed to use dialog outerWidth & outerHeight
这篇关于如何在 jQuery UI 对话框上设置包含?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!