这里是使用 jquery UI 的 angularJS 指令。我想设置可以在调整大小函数中调整大小的元素的最大宽度。这怎么可能?
app.directive('resizable', function () {
return {
restrict: 'A',
scope: {
callback: '&onResize'
},
link: function postLink(scope, elem, attrs) {
elem.resizable({ grid:200, handles: 'e,w'});
elem.on('resize', function (evt, ui) {
scope.$apply(function() {
if (scope.callback) {
scope.callback({$evt: evt, $ui: ui });
//here is where I want to set maximum width
}
})
});
}
};
});
最佳答案
根据API docs您只需设置 maxWidth
选项:
$( ".selector" ).resizable({
maxWidth: 300
});
您也可以动态调用它:
$( ".selector" ).resizable( "option", "maxWidth" );
事实是,如果您从调整大小事件处理程序调用它,我认为更改只会影响下一个触发器。
关于javascript - 用于使用 jquery ui 调整大小的 Angular js 指令无法设置最大宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37206136/