Hidden in jQuery Mobile's own documentation . I found an approach that worked fine for the search box + . strong> implementation.
On this page, they compare things side by side using a simple <table> layout that inspired me to do the same. While tables are NOT a suitable resource for proper layout / design, it is extremely efficient, simple, and bypasses many of the workarounds that I see here. Here is what my approach can do for your jsfiddle you linked . See Fourth Iteration.
In other words, due to the complex nature of how jQuery Mobile creates a page, adds to the div and style that are not in your layout, etc., this might be your best option for this particular scenario:
- Two columns of elements are required where the second column is fixed.
- When the first column expands to fill the width of the screen when resizing.
- Where you want elements to cover the entire width of the device.
(Remarkably, if you want to customize any of these aspects, some simple CSS add-ons or alignment should do the trick starting with this basic solution)
<table style='width:100%'><tr> <td> <input type='text' (or type='search') /> </td> <td style='font-size:80%; width:7em'> <input type='submit' value='Submit' /> </td> </tr></table>
Obviously, you must name and give id these elements if you want to place them somewhere or manipulate them in javascript. Hope this proves useful to someone who is not estranged from the nature of <table> s. I could not see the drawback of this approach using jQuery Mobile's simple interface / theme.
Finally, you can stop and ask yourself if you need a submit button. On mobile devices, such as mobile safaris, there is a button on the keyboard labeled “Go” that interacts with form input elements. This works the same as the return key, and can submit a search request. Currently, I have not tested this option in other browsers.
(This is not a solution to rival your approach to move the search box icon. It's very smart, but it doesn't seem to be what your original question was talking about.)
veeTrain
source share