Results 1 to 15 of 15
  1.    #1  
    How in the world do you create event listeners for widgets inside of a list widget? The Pre freezes when you try and set it up the conventional way.

    Mojo.Event.listen(this.controller.get('checkBox'),Mojo.Event.propertyChange,this.handleCheckBox.bind AsEventListener(this));

    This doesn't work when the widget class ID is embedded inside of a list widget.
  2. #2  
    It won't work like that. You need listen for a listTap on the list itself, then in the listener, you would look for event.originalEvent which will contain the actual propertyChange event.
  3.    #3  
    Quote Originally Posted by Blubble View Post
    It won't work like that. You need listen for a listTap on the list itself, then in the listener, you would look for event.originalEvent which will contain the actual propertyChange event.
    Ok. it still wont trigger the listTap when you click on the checkBox widget. I see what your saying, but the listTap only seems to work when you click anywhere other than the check box.
  4. #4  
    Have you tried listening for the propertyChange on the list itself. It isn't one of the list events, but it might bubble up. You might also place the list inside another element and listen there.

    Are you a member of the early access program?
  5.    #5  
    Quote Originally Posted by Blubble View Post
    Have you tried listening for the propertyChange on the list itself. It isn't one of the list events, but it might bubble up. You might also place the list inside another element and listen there.

    Are you a member of the early access program?
    No, unfortunately not. I just read on another site -

    " Note: If you embed widgets within your row template, you must instantiate them in your StageAssistant by using the name parameter. "

    I'm a little fuzzy on that. Name parameter? Isn't that what I was doing?
  6. #6  
    Do you have an id on the checkbox element? I remember reading somewhere that when you have controls inside a list, you should only use name instead of id.
  7.    #7  
    Quote Originally Posted by Blubble View Post
    Do you have an id on the checkbox element? I remember reading somewhere that when you have controls inside a list, you should only use name instead of id.
    Ok. I've assigned a name tag instead of id.
    What is the name equivalent of getElementbyID then?
  8. #8  
    Cleverly, it's getElementsByName()

    BUT

    get elements by name always returns an array, since names are not nessesarily unique.

    So, assuming that there is one element with the name "checkbox1" you have to do

    document.getElementsByName("checkbox1")[0].whatever

    DOM sucks.
  9. #9  
    Hi Mattbrad2, I'd def appreciate it if you post the solution to this when you solve it. I can see needing to do something like this myself eventually.
    Thanks.
  10.    #10  
    Quote Originally Posted by schoksi View Post
    Hi Mattbrad2, I'd def appreciate it if you post the solution to this when you solve it. I can see needing to do something like this myself eventually.
    Thanks.
    I certainly will. I'm still having problems with it. Even when using getelementsbyname it still freezes up. Working on it now..
  11.    #11  
    The problem is that the DIV for the checkbox widget (or any other widget for that matter) is not in the scene html file. It's in the row template html. WebOS has no idea what ID (or NAME) you are referencing.

    My search continues..
  12. #12  
    I think Blubble hit the nail on the head. Mitch Allen writes:

    "You can't set up a listener to the toggle, but you can listen to Mojo.Event.propertyChange"

    ...

    "For example:

    this.controller.listen("myList", Mojo.Event.propertyChange, this.toggleChange.bindAsEventListener(this));"

    Take a look on pg. 75
  13. corpx's Avatar
    Posts
    209 Posts
    Global Posts
    219 Global Posts
    #13  
    I have the same problem as you matt.

    I'm trying to have a bunch of rows, each of which spawn a drawer when tapped.

    The rows are populated using a template, so I cant seem to figure out a way to listen to the taps.


    Anyone?
  14. #14  
    Huzzah thread necromancy, but I bet people are going to want this info. I just figured out how to do this in my app, but it was a little tricky.

    First, I needed to add a unique ID to the drawer's div in the itemTemplate file, which I did by appending the "id" value from my list object:
    Code:
    <div x-mojo-element="Drawer" name="myDrawer" id="myDrawer#{id}">
    Next, I set up a listener for listTap:
    Code:
    this.controller.listen("myTemplateList", Mojo.Event.listTap, this.listTapped.bindAsEventListener(this));
    Finally, here's how you toggle the drawer in the listTapped function:
    Code:
    MyAssistant.prototype.listTapped = function(event) {
    	try {
    		var drawer = "myDrawer" + event.item.id;
    		this.controller.get(drawer).mojo.toggleState();
    	} catch (e) {
    		Mojo.Log.error("listTapped: " + e);
    	}
    }
    And voila, the drawer toggles. Let me know if you can get this to work for you too.
    Last edited by DeusInnomen; 09/05/2009 at 08:50 PM. Reason: Typo.
  15. #15  
    I had the same scenario as the OP, where my row template includes a CheckBox, and changing a CheckBox's state didn't trigger the Mojo.Event.listTap event.
    FirstStryke's suggestion of watching for Mojo.Event.propertyChange was spot on!

Posting Permissions