change the NumberSpinner attr dynamicaly
I have initialized the NumberSpinner in the following way.
var spinner = new dijit.form.NumberSpinner({
name:"spinner",
value: "0",
smallDelta:"10",
constraints: {
min: "0"
},
style:'width:100px'
},
"container");
what i need to do is change the smallDelta value dynamically according to other selections. Is there any way to remove smallDelta attribute. If it can be done I can use set method to set the att开发者_如何转开发ribute with different value. any help?? Thanks in advance
You can change the smallDelta value dynamically using spinner.set('smallDelta', yourValue);
Take a look at this jsfiddle:
markup:
<body class="claro">
<div id="container">
</div>
<input id="increaseDelta" dojoType="dijit.form.Button" label="increase delta">
<input id="decreaseDelta" dojoType="dijit.form.Button" label="decrease delta">
</body>
javascript:
dojo.require('dijit.form.NumberSpinner');
dojo.require('dijit.form.Button');
dojo.ready(function() {
var spinner = new dijit.form.NumberSpinner({
id: 'spinner',
name: "spinner",
value: "0",
smallDelta: "10",
constraints: {
min: "0"
},
style: 'width:100px'
}, "container");
dojo.connect(dijit.byId('increaseDelta'), 'onClick', function() {
var spin = dijit.byId('spinner');
var currentDelta = spin.get('smallDelta');
console.log(currentDelta);
spin.set('smallDelta', parseInt(currentDelta) + 10)
});
dojo.connect(dijit.byId('decreaseDelta'), 'onClick', function() {
var spin = dijit.byId('spinner');
var currentDelta = spin.get('smallDelta');
console.log(currentDelta);
spin.set('smallDelta', parseInt(currentDelta) - 10)
});
});
精彩评论