English 中文(简体)
dijit. form. 数字Spinner 的增量/降量事件
原标题:increment/decrements events for dijit.form.NumberSpinner

如果 dijit. form 内部的值被递增或衰减, 有没有办法赶上事件? NumberSpinner 部件被递增或衰减?

我打算做的是,每当数值在数字Spinner元件中值低于 0 设定的文本为“ 永远” 时, 当用户从“ 永远” 增加时, 值应该再次设定为 0 。

最佳回答
dojo.declare("MySpinner", [Spinner], {

    zeroValue:  Never ,

    adjust: function(/*Object*/ val, /*Number*/ delta){
        arguments[0] = val && val > 0 ? val : 0;
        return this.inherited(arguments);
    },

    _getValueAttr: function() {
      var v = this.inherited(arguments);
      return (!v || v <= 0) ? 0 : v;
    },

    format: function(/*Number*/ value, /*dojo.number.__FormatOptions*/ constraints){
      var v = this.inherited(arguments);
      if (v <= 0 || !v) 
         return this.zeroValue;

      return v;
    },

    isValid: function(/*Boolean*/ isFocused){
        var v = this.get( value );
        if (!v) {
            return true;
        }           
        return this.inherited(arguments);
    }
});  

此处的示例

http://jsfiddle.net/cswind/zDVep/

问题回答

暂无回答




相关问题
Get Dojo Radio Button Value?

I have an HTML form using dojo and have the following code for a radio button selection choice: dojo.require("dijit.form.RadioButton"); <link href="http://ajax.googleapis.com/ajax/libs/dojo/1....

is it possible to know if a dijit is displayed or not?

i have two divs on a page. each has several dijits. i have atoggle that shows only one div or the other. when i submit the form, i only want to validate the dijits that are in the div that is ...

dijit BorderContainer auto-grow

Is there a way to have a dijit.layout.BorderContainer auto-grow in height? I ve tried setting min-height: 200px; height: auto;, but it won t scale. I ve tried looking at the API, but that thing is a ...

Dojo Tabs as Custom Widgets

I ve created a number of widgets that are loaded as tab panes in a tabcontainer. Everything seems to work well, except I m getting different results when using my custom widgets vs. creating ...

What happened to Dojo DOH?

The Dojo Toolkit used to come with a testing facility called "Doh". It was in the /utils directory. Now when you download dojo-release-1.3.2 the /utils directory is nowhere to be found. Is Doh dead ...

热门标签