Reputation: 4305
I am using Extjs 4 and overriding a Ext.util.Observable
as the name Ext.tree.Search
. In the extended class I have implemented event listener onTriggerSearch
so when the user types some words in input and presses enter key, this function is get called and do some search job. The search plugin has a view like the image below:
If the user submit the search by pressing magnifier icon, everything goes right but if press enter key, after doing the search, the page gets refreshed. How should I catch this event (key press event) completely and stop propagating. The thing I have tested by now is lines below:
, onTriggerSearch: function (a, event, c) {
// stop event propagation
if (event.browserEvent.stopPropagation)
event.browserEvent.stopPropagation();
if (event.browserEvent.cancelBubble != null)
event.browserEvent.cancelBubble = true;
// event.browserEvent.bubbles = false;
// event.browserEvent.cancelBubble = true;
// event.browserEvent.stopPropagation();
// ======================
... some other jobs
return false; // to stop propagation
}
Upvotes: 0
Views: 1667
Reputation: 4305
There was some weeks I had trouble with this issue and by now I have discovered that the problem is with the form containing this input. I have prevented form to submit using these answers:
How to prevent ENTER keypress to submit a web form?
Done.
Upvotes: 1