Results 1 to 8 of 8
  1.    #1  
    So I'm getting a little annoyed with webos programming. What I want to do is create buttons dynamically. Right now what I am doing is calling my create button method that does either of the two examples to create a button by inserting html into a division.

    this.controller.get('myDiv').innerHTML += "<div x-mojo-element='Button' id = '"+ buttonID +"'></div>";


    $('myDiv').insert("<div x-mojo-element='Button' id = '"+ buttonID +"'></div>");


    Using either one of these lines creates a button in my application. But it seems I'm only able to create buttons in the setup method. What I want to do is create buttons in a Mojo.depot callback or in the considerForNotification.

    What am I doing wrong??? Thanks for the help.
  2. tc600's Avatar
    Posts
    305 Posts
    Global Posts
    306 Global Posts
    #2  
    I think they do need to be in your Setup method. Do you have a set maximum number of buttons? If so, you could put them in the Setup method and hide the unnecessary ones, then make them visible as needed.
  3. #3  
    As tc600 mentioned, widgets need to be created in the Setup method of the scene assistant. If the number of buttons needed is truly dynamic, then perhaps you could dynamically add standard HTML DIV buttons instead of Mojo button widgets. And you could make them look any way you'd like via CSS styling.
    Quick Post: The quick way to post messages and photos to Twitter & Facebook (video link)
    Music Player (Remix): The next generation music listening experience on webOS (video link)
    GeoStrings: Set location-based reminders and never forget another task (video link)

    Twitter: @Hedami
  4. mosdl's Avatar
    Posts
    781 Posts
    Global Posts
    787 Global Posts
    #4  
    You can easily create dynamic widgets in webOS:

    Code:
      this.controller.setupWidget("widgetid", this.attributes = {}, this.model = {});
      this.controller.update($("containerId"), '<div id="detailsList" x-mojo-element="List"></div>');
      this.controller.instantiateChildWidgets($("containerId"));
    that creates a dynamic list.
    Apps: MyQ for Netflix (Phone/TouchPad), Giantbomb (Phone), Excavate (Reddit/Digg clients for TouchPad)
  5. #5  
    Quote Originally Posted by mosdl View Post
    You can easily create dynamic widgets in webOS:

    Code:
      this.controller.setupWidget("widgetid", this.attributes = {}, this.model = {});
      this.controller.update($("containerId"), '<div id="detailsList" x-mojo-element="List"></div>');
      this.controller.instantiateChildWidgets($("containerId"));
    that creates a dynamic list.
    Wow that's good to know...I never knew that.
    Quick Post: The quick way to post messages and photos to Twitter & Facebook (video link)
    Music Player (Remix): The next generation music listening experience on webOS (video link)
    GeoStrings: Set location-based reminders and never forget another task (video link)

    Twitter: @Hedami
  6. #6  
    why don't use use changeModel instead of digging in html?
  7.    #7  
    Thanks for all the help.

    Boucles - Could you give me some more info on the changeModel or point me in the direction of where I could find more info?

    mosdl - I wasn't able to get the dynamic list code working for my buttons after the setup function.

    tc600 - If I were to just setup a bunch of buttons on startup. How can I access them after the fact and update the button names and the visibility of the button.

    Thanks
  8. #8  
    I used drawers that I switched around (it's kind of a pain to keep track of what's open and what's closed if you have a lot of buttons).

    That worked quite smoothly.

    I'm sure mosdl's suggestion probably works better though.

Posting Permissions