×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    29

    Getting info from a TransitionList

    Hi,

    I was just playing with the TransitionList component of the GuaranaUI and I am not sure how to "know" which item was clicked.

    e.g.

    Code:
    myList = new Nokia.TransitionList({
    			element: '#mylList',
    			title: 'My List',
    			visible: true,
    			create: function() {},
    			show: function(openerTransitionList) {},
    			hide: function() {},
    			addItem: function(event, item) {	},
    			removeItem: function(event, item) {}	
    		});
    Then I created 10 objects:

    Code:
    		for (var i = 0; i < 10; i++)
    		{
    			myList.addItem (
    				new Nokia.TransitionListItem({
    					label: 'Item No. ' + i,
    					click: function (){}
    				})
    			);
    		}
    I tried putting an alert(i) but it doesn't work because i was constantly changing.
    Can someone advise?

    Many thanks!

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Getting info from a TransitionList

    Hi,

    you could try with this code:

    Code:
    for (var i = 0; i < 10; i++)
    {
    	myList.addItem (
    		new Nokia.TransitionListItem({
    			label: 'Item No. ' + i,
    			myIndex: i,
    			click: function () {
    				alert(this.options.myIndex);
    			}
    		})
    	);
    }
    Hope it helps,
    Pit

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    29

    Re: Getting info from a TransitionList

    Quote Originally Posted by jappit View Post
    Hi,

    you could try with this code:

    Code:
    for (var i = 0; i < 10; i++)
    {
    	myList.addItem (
    		new Nokia.TransitionListItem({
    			label: 'Item No. ' + i,
    			myIndex: i,
    			click: function () {
    				alert(this.options.myIndex);
    			}
    		})
    	);
    }
    Hope it helps,
    Pit
    Hi, thanks! That kinda helped.

    How about if I want to know what was the item I clicked that got me there in a multi-level list?

    e.g. The menu structure as below

    myList
    - Item 1
    --- sub item 1
    --- sub item 2
    - Item 2
    --- sub item 1
    --- sub item 2
    - Item 3
    --- sub item 1
    --- sub item 2

    Say when I click sub item 2 under item 1, how do I get the info/id/label that I came from Item 1?

    Hope this is not too confusing..

    Thanks again for your kind assistance!

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Getting info from a TransitionList

    Hi,

    probably not the best possible solution, but you could try by storing the index of the clicked first-level element in a variable, and use this to identify where you came from.

    Hope it helps,
    Pit

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    29

    Re: Getting info from a TransitionList

    Hmm..

    Since the transitionlist doesn't seem ideal, is there any other tool that you would recommend that I can use?

    I simply need to know which option the user selects on the first menu when I'm say, in the 2nd or 3rd level menu..

    Many thanks!

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Getting info from a TransitionList

    Hi Aimevous,

    actually the transition list seems to be suitable for your needs: if you need multi-level menus, it gives you this functionality just ready to be used. My solution (of using a variable) is just a sample, but you can most probably find other (and probably more elegant) alternatives.

    Of course you could implement your own lists from scratch, but it would require slightly more time than by using Guarana UI.

    Pit

Similar Threads

  1. Info
    By robalo in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-07-22, 11:00
  2. info 2
    By bulbulov in forum Mobile Java General
    Replies: 3
    Last Post: 2005-03-27, 12:46
  3. Accessing network info from Java and location based info in Australia
    By T-Funk in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2002-12-09, 09:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×