ruby on rails - Selecting active option in jQuery Mobile -
The mobile page for my app is the header with the menu menu select the jQuery Mobile dropdown.
& lt; Span data-role = "fieldcontain" id = "category-dropdown" & gt; & Lt; Select name = "selection-country-2" id = "selection-country-2" data-mini = "true" & gt; & Lt; Option value = "& lt;% = root_path%>" & Gt; Home & lt; / Options & gt; & Lt; Option value = "& lt;% = newest_path%>" & Gt; New & lt; / Options & gt; & Lt; Option value = "& lt;% = group_path (group.fund (1))% & gt;" & Gt; Group 1 & lt; / Options & gt; & Lt; Option value = "& lt;% = group_path (group.fund (2))%>" & Gt; Group 2 & lt; / Options & gt; & Lt; Option value = "& lt;% = group_path (group.fund (3))% & gt;" & Gt; Group 3 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Span & gt; I am using JavaScript below to navigate to the selected page.
& lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ("# select-native-2"). Change (function () {if ($ (this) .val ()! = '') {Window.location.href = $ (This) .val ();}})}}; & Lt; / Script & gt; My problem is, when a user redirects to another page, the first option ("home") is selected back menu. How can I select the current page reflect the current page?
My guess is that I need to have the # 1 symbol
option which is "active," # 2 Make sure Javascript is enabled on selectmenu . What is the best way to do those two things?
I can do the # 1 below, but it is quite ugly For # 2, I'm not sure what is the best way to select it. Appreciate your input! Why not use the <<> selected selected attribute?
& lt; Span data-role = "fieldcontain" id = "category-dropdown" & gt; & Lt; Select name = "selection-country-2" id = "selection-country-2" data-mini = "true" & gt; & Lt; Option value = "& lt;% = root_path%>" & Gt; Home & lt; / Options & gt; & Lt; Option value = "& lt;% = newest_path%>" & Gt; New & lt; / Options & gt; & Lt; Option selected value = "& lt;% = group_path (group.fund (1))% & gt;" & Gt; Group 1 & lt; / Options & gt; & Lt; Option value = "& lt;% = group_path (group.fund (2))%>" & Gt; Group 2 & lt; / Options & gt; & Lt; Option value = "& lt;% = group_path (group.fund (3))% & gt;" & Gt; Group 3 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Span & gt; This will make the selected option "Group 1" on the page load. You have to find out which options will get this feature. But it should be easy to do so by Ruby.
Comments
Post a Comment