更改jQuery Knob Min / Max值 [英] Change jQuery Knob Min/Max value
本文介绍了更改jQuery Knob Min / Max值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为jquery-knob小部件设计一个角度包装器。只要最大值不变,以下工作。如果是这样,则ng模型绑定将丢失。如果我没有在手表开头销毁旋钮小部件,则最大值不会改变。
I'm working on an angular wrapper for the jquery-knob widget. The following works as long as the maximum value doesn't change. If it does, the ng-model binding is lost. If I don't destroy the knob widget at the beginning of the watch, the max value doesn't change.
//Directive
app.directive('knobWidget', function () {
return {
scope: {
maxbinding: "=maxbinding",
maxbindingprop: "@maxbindingprop"
},
restrict: 'A',
require: 'ngModel',
link: function (scope, elem, attrs, ngModel) {
ngModel.$render = function () {
$(elem).val(ngModel.$viewValue).trigger("change");
};
scope.$watch('maxbinding', function (newVal) {
$(elem).knob('destroy');
$(elem).knob({
min: 0,
max: scope.maxbinding[scope.maxbindingprop],
value: ngModel.$viewValue,
change: function (changeVal) {
scope.$apply(function () {
ngModel.$setViewValue(changeVal);
});
}
});
});
}
};
});
//Markup
<input knob-widget data-min="0" maxbinding="arr" maxbindingprop="length" ng-model="currentStop" />
执行:
$(elem).knob('max', scope.maxbinding[scope.maxbindingprop]);
也不起作用。有什么想法?
doesn't work either. Any ideas?
推荐答案
使用触发器('configure')
后跟触发器('更改')
应该诀窍
$(elem).trigger('configure', {
'max': scope.maxbinding[scope.maxbindingprop];
});
$(elem).trigger('change');
这篇关于更改jQuery Knob Min / Max值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文