Dojo textBox doesn't accept whitespace

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 19:23:42

问题


I'm working with no experience on a Dojo project and don't know which version I'm working on.

There is a textBox for a search form which doesn't accept whitespace. I searched in this documentation for a solution, but no method seems to be applicable. http://dojotoolkit.org/api/dijit/form/TextBox

So my question is: is it possible to accept whitespace in a textBox form or is it just possible with a ValidationTextBox?

me.filterBox = new TextBox({
            style: 'margin-bottom: 0',
            class: 'STQuicksearch',
            trim: false,
            intermediateChanges: true,
            placeHolder: 'Quick search'
         });

Edit: There is no difference between setting trim false or true. But that's not my problem: I need to put whitespace between multiple words. Trim only removes leading and trailing whitespace!


回答1:


If you look carefully in the documentation, you will find that the TextBox has a trim property, which removes leading and trailing whitespace if true. Setting this to false will hopefully give you the desired result.




回答2:


Coded a working solution:

me.filterBox = new TextBox({   
   ...
   onKeyDown: function(e) { 
      if (e.keyCode === keys.SPACE) {
          this.set('value', this.get('value')+' ');
      }
   }
});


来源:https://stackoverflow.com/questions/17574765/dojo-textbox-doesnt-accept-whitespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!