| 79 | | //overload isValid/setValue to not show any validate error: if invalid, just show empty in the widget |
| 80 | | this.button.isValid = function(){ return true; }; |
| 81 | | this.button.setValue = function(/*String*/ value, /*Boolean?*/ priorityChange){ |
| 82 | | //copied from FilteringSelect.setValue, just added one line |
| 83 | | //TODO: is there a better way to achieve this? or shall we add a hook to |
| 84 | | //FilteringSelect.setValue to allow inserting a _setValue more easily? |
| 85 | | var self=this; |
| 86 | | var handleFetchByIdentity = function(item, priorityChange){ |
| 87 | | if(item){ |
| 88 | | if(self.store.isItemLoaded(item)){ |
| 89 | | self._callbackSetLabel([item], undefined, priorityChange); |
| 90 | | }else{ |
| 91 | | self.store.loadItem({ |
| 92 | | item: item, |
| 93 | | onItem: function(result, dataObject){ |
| 94 | | self._callbackSetLabel(result, dataObject, priorityChange); |
| 95 | | } |
| 96 | | }); |
| 97 | | } |
| 98 | | }else{ |
| 99 | | self._isvalid=false; |
| 100 | | self.validate(false); |
| 101 | | self._setValue('','',false); //added this line to reset the input field to empty |
| 102 | | } |
| 103 | | } |
| 104 | | this.store.fetchItemByIdentity({ |
| 105 | | identity: value, |
| 106 | | onItem: function(item){ |
| 107 | | handleFetchByIdentity(item, priorityChange); |
| 108 | | } |
| 109 | | }); |
| 110 | | } |