问题
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