2

I've done a jquery-mobile controlgroup using input buttons like this:

<div data-role="controlgroup" data-type="horizontal" class="panelSwitcher">
   <input type="button" data-iconpos="notext" data-icon="gallery" value="Gallerie" class="viewGrid" />
   <input type="button" data-iconpos="notext" data-icon="panels" value="Panels" class="viewPanel" />
   <input type="button" data-iconpos="notext" data-icon="detail"  value="Detail" class="viewDetail"  />
</div>      

I'm using this to switch views (add/drop a single class, rest CSS), so I don't really want to do this using link tags (empty href/alt) and event-binding. Radio-button-form is also too complicated, plus you cannot do icon only radios.

So input type=button.

Question:
I'm loading my page in gridview, so I want to have the gridview button preselected. I know I can jQuery addClass('ui-btn-active') to the parent .ui-btn element, but I want to know if there is a markup-only solution, too?

2 Answers 2

4

I know this was answered some time ago, but I think the correct answer is to set add the "ui-btn-active" class on the div containing the button.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this, but i am using radio buttons and when adding the active class to the label it would be highlighted for the first call but remains if i select another option. any idea?
1

I have tried to find a solution by giving a data-theme="b" for the selected button. data-theme="b" closely resembles the active state. A demo here - http://jsfiddle.net/hz9Q3/

Let me know if that helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.