Is there anyway to add a select box inside the header?
I have tested with this code
<div data-role="header" data-position="inline" data-theme="b">
<h1>My Page</h1>
<select>
<option>Option 1</option>
<option>option 2</option>
</select>
</div>
but it doesn’t work
Edit:
sorry because the question is not so clear. With the above code, i have a select box in the header, but the select box is centered (underneath the page title). Which i want is that, the select is placed on the right(just like a button inside header).
|[back] ——— Title ———– [select box]|
What do you see / not see exactly? I placed your code in a jQuery Mobile page, and I got a select field as expected in the page header. Here’s the code snippet I used, which checks out OK in Desktop and Mobile Safari (iPad):
EDIT
I think the issue you run into is that
h1is a block element of course, and so is theselectfield once jQM has run its code. If you inspect the field once the page is rendered in a WebKit browser, you will see that jQM applies extra divs and the like, which means that the select field can’t easily reside on the same line as your header.According to the docs, you need to experiment with custom mark-up in the header by placing it in its own
div(so jQM doesn’t try to manipulate it) and then styling it yourself. The kind of look you want to achieve is best done when building a header bar with two links it, but obviously that doesn’t apply for you because the second “button” isn’t a link, it’s aselectfield:You could try doing something like this to fudge it, but you’d need to test across the devices you’re supporting in your app (and obviously put the styles in a class, I’ve only done it this way for example purposes):