For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 6 replies, 3 voices, and was last updated 13 years, 2 months ago by
MichaelJeffress.
-
AuthorPosts
-
MichaelJeffressMemberDear Tech Support:
** A Function to always Return Label Name of the Last Clicked and or Selected Menu Items **
[b]Using the following code I have been able to grab the label text for a SelecListtMenu type with multiple selection allowed.[/b]
var summary = “”;
var summary2 = “”;
//multiple select list: get selected items as array
var sumtext1 = $(‘select[name=”selectListMenu1″] :selected’).each(
function(i, selected) {
summary += $(selected).text() + “::” + $(selected).val() + “\n”;
summary2 += $(selected).text() + “? “;
});
var summary3 = summary2.split(“?”); var p1 = summary3.length;However, assuming the following menu structure, the code above gets me the checked items: Apples, Bananas, Blue. But I am not able to retrieve the labels to top menu items. For example: How do get both lables, “Fruit” and the children items: “Apples, Bananas.”
Also, you will notice in the example, there are mixed elements making up the “list”. I need to get grab the menu label rather it is “Fruit” (a SelectlistMenu) or “Marbles” (a regular listItem).
.
My MENU
——————–
Fruit (SelectListMenu1)————————————————>
————————————————-Apples X
————————————————-Oranges
————————————————-Bananas X
Planets (SelectListMenu2)————————————————->
————————————————–Earth
————————————————–Pluto
————————————————–Venus
——————–
Marbles (listItem1)———————
Widgets (listItem2)
__________________
Socks (listItem3)
———————
Colors (SelectListMenu3)
————————————————->
– ———————————————–Red
————————————————-Blue X
———————————————— GreenBasically, I need the code that would always return the label name for both “Clicked” and/or “Selected” elements. Your help with this matter would be greatly appreciated !
Best Regards,
MikeJune 26, 2012 at 9:43 am #327593
support-octavioMemberHi MJConsulting,
We don’t understand clearly what you’re requesting. Can you give us more details about your app for a better advice?? Do you only need to know in where section you are?
June 26, 2012 at 12:04 pm #327595
MichaelJeffressMemberHi Octavio,
Thanks for getting back to me.
Here is the behavior and my problem. Please see attached:
(1) If I click Apple, click Grape, Banana, I successfully get the labels names (“Apple”,”Grape”, “Banana”).
(2) If I now click Orange and then click “Orange-submenu2”, I now get Apple, Grape, Banana, Banana, and “Orange-submenu2” as label names. However, and this is my problem: I am never able to get “Orange” (which has the run screen on click). I do get the Screen2 Menu labels, but not the “parent” Label, if you will, in this case, “Orange.”
(3) I need to get all label names on Clicked menu items, even when they (a) have sublist items or (b) run a mobi screen or link to external resources.
Attachments:
You must be logged in to view attached files.June 26, 2012 at 1:37 pm #327604
BrandonMemberI believe you could do something like this (untested code)
function getListItem() { //get label/text of selected item mySelected = $('select[name="selectlist1"] :selected').text(); if (mySelected == 'Apples') { //Open the new page phoneui.gotoPage("m1-pagename"); }
and just call the function getListItem() when the list is clicked.
June 26, 2012 at 7:02 pm #327626
MichaelJeffressMemberHi CincyPlanet, and thanks for your suggestions.
Perhaps I am overlooking something, but when I try this logic, the hml page which contains the new (sub) menu target page is not available. It appears that only lnked pages are available. Using your suggested method, the target pages are no longer linked in MobiOne to any event, therefore, I get page not available when I try calling the target page.
In other words, to use your example:
Am I overlooking something?
Regards,
MikeJune 27, 2012 at 7:56 am #327642
BrandonMemberIn mobione if you dont link to the pages they wont be included in the final compile, I already ran into this. An easy fix is to add a link text component, link it to the page you want, then double click and delete the actual text, this way you still have the link and the page will be included, but the unwanted link text doesnt show. That should allow you to use the code concept.
June 27, 2012 at 9:09 am #327644
MichaelJeffressMemberHi CincyPlanet:
Thanks for your suggestion. It will work — I had already started that exact work-around !
Thanks again.
Regards,
Mike -
AuthorPosts