Results 1 to 6 of 6
  1.    #1  
    Hi,

    I have a problem with a list Widget. It works fine but I don't know how to access to one item.

    I have tried this to get for exemple the second item of the list

    Code:
    var listitem= this.controller.get('my_list').mojo.getNodeByIndex(1);
    or this

    Code:
    var listitem= this.listModel.mojo.getNodeByIndex(1);
    I'm creating my list using this

    Code:
    var newItem = {data:$L(mydata), adresse:$L("myadresse")};
    Nothing seems to work ? Has anyone an idea ? Thanks for answers !
  2. #2  
    Do you want to access the entire row, html and all? Or do you just want to access the value of that row's item?
  3.    #3  
    only the value of a row item.

    I also tried : var listitem = this.listModel.items[1]; but it returns "[Object object]"
  4. #4  
    Well, say your items model looks like this:
    Code:
    this.listModel = {
        items: [
            { title: 'someStuff', content: 'someMoreStuff' },
            { title '...', content: '...' },
            ...
        ]
    }
    Then I think you would need to use:

    Code:
    this.listModel.items[i].title
    to get the title say. I think it's dependent on what the members of each array item are called if you see what I mean.
  5. #5  
    Quote Originally Posted by boucles0 View Post
    I also tried : var listitem = this.listModel.items[1]; but it returns "[Object object]"

    well, [Object object] is the string representation of an object.

    So in your example, listitem.data == $L(mydata)
  6.    #6  
    Quote Originally Posted by semprance View Post
    Well, say your items model looks like this:
    Code:
    this.listModel = {
        items: [
            { title: 'someStuff', content: 'someMoreStuff' },
            { title '...', content: '...' },
            ...
        ]
    }
    Then I think you would need to use:

    Code:
    this.listModel.items[i].title
    to get the title say. I think it's dependent on what the members of each array item are called if you see what I mean.
    yeeeaaahhhhh ! that works perfectly ! thousand of thanks for you, I've been wasting two hours on this....

Posting Permissions