I've resolved both issues))
1) About event on pressing Search button(enter)
There is an issue in IOS Safari with appearing "Search button" on virtual keybord.
your text input with type="search" must be inside form tag.
Show 'Search' button in iPhone/iPad Safari keyboard
(second answer)
To call some function on pressing Search button and not submit a form I put the following javascript into the from tag:
<form onsubmit="myFunction(...);return false;">
Pressing Search button starts the Submit action. And this javascript call my function at this time and stop the submitting. That's what I need!
2)
The second problem with clear button of the search box.
This is the bug of dojo. https://bugs.dojotoolkit.org/ticket/16672
I've found a workaround. http://dojo-toolkit.33424.n3.nabble.com/dojox-mobile-SearchBox-Clear-Button-x-fails-in-iPad-iOS-16672-td3995707.html
But I change it a little, cause it does not work in my case.
This is the my variant:
<form onsubmit="myFunction(...);return false;">
<input id="searchBox" ontouchstart="clearButtonSupport(event);" data-dojo-type="dojox.mobile.SearchBox"
data-dojo-props="type:'search'" type="search"
placeholder="Some placeholder...">
</form>
This is the clearButtonSupport function:
function clearButtonSupport(evt) {
require([ "dijit/registry", "dojox/mobile/SearchBox" ], function(registry) {
var searchBox = registry.byId('searchBox');
var rect = document.getElementById('searchBox').getBoundingClientRect();
// if touched in the right-most 20 pels of the search box
if (rect.right - evt.touches[0].clientX < 20) {
evt.preventDefault();
searchBox.set("value", "");
}
});
}
onclick and onmouseup event in IOS safari works only when text input is not focused.
If the focus on the search box(cursor is inside) this event is not thrown.
So i used ontouchstart event
ontouchstart - multitouch event in IOS safari.
It's thrown every time you touch the element.
So I take the coordinates of the first(and the only) touch.
And look if it's less than 20px far away from the right side of the element.()position of the clear button)
And clear the search box.
That's it!