Results 1 to 10 of 10
  1.    #1  
    How do I obtain the value from a TextField Widget?

    I have tried:

    Code:
    this.controller.get("WidgetID").mojo.getValue();
    I am trying to set it to the innerHTML of my div:

    Code:
    $('divid').innerHTML = this.controller.get("WidgetID").mojo.getValue();
    I have tried so many things and nothing returns the value back.

    It just comes back undefined?
  2. #2  
    When you setup the TextField Widget, define that model into a variable, like below:

    Code:
    this.controller.setupWidget("textFieldId",
            this.attributes = {
                hintText: $L("  ... and hit Enter"),
                multiline: false,
                enterSubmits: false,
                focus: true
             },
             this.model = {
                 value: "",
                 disabled: false
             }
        );
    Then you can get the value of that text field using that variable and set it in your div i.e.,

    Code:
    $('divid').update(this.model.value);
    It is cleaner and elegant to use the update method than using innerHTML

    Thanks
    M
  3.    #3  
    I have this:

    Code:
    this.controller.setupWidget("MyTextFieldWidget",
            this.attributes = {
                hintText: $L("0.00"),
                multiline: false,
                enterSubmits: false,
                autoFocus: true,
             modifierState: Mojo.Widget.numLock
             },
             this.MyTextFieldWidget = {
                 value: '',
                 disabled: false          
             }
        );
    So I am assuming I can do this then:

    Code:
    $('divid').update(this.MyTextFieldWidget.value);
    I am assuming I need to give the "model" a different name for each one so I can reference them by this.[model name]?

    I am going to try the .update method and see what happens.

    The Palm SDK documentation sucks and I see a lot of people have this issue.
  4.    #4  
    I created a method called SetupWidgets which sets up all my widgets and that seems to work fine.

    I think do this for the Changed event:

    Code:
    Mojo.Event.listen(this.controller.get('amountSpent'), Mojo.Event.propertyChange, this.amountSpentChanged);
    Then I have this in the changed method:

    Code:
    MainAssistant.prototype.amountSpentChanged = function(event){
    	Mojo.Controller.getAppController().showBanner("Welcome to my first app!", {source: 'notification'});
    	$('totalOwed').update(this.amountSpentModel.value);
    };
    The notification happens, but if I put the notification after trying to set the value it never happens.

    It seems to die on this line:

    Code:
    $('totalOwed').update(this.amountSpentModel.value);
  5. #5  
    What does the log say?
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  6.    #6  
    Quote Originally Posted by unfairSurprisery View Post
    What does the log say?
    Well I changed the code around some and it says unhanded exception 'get' not valid

    This doesn't work:
    Code:
    this.controller.get("totalOwed").update(this.controller.get('amountSpent').getValue());
    I am able to update by doing this:
    Code:
    $('totalOwed').update('Hello');
    If I put the .get method in the setup it works fine, for some reason it can't seem to find it in my method though.

    I have a notification that goes off, so I know it reaches the method:
    Code:
    Mojo.Controller.getAppController().showBanner("Welcome to my first app!", {source: 'notification'});
    I'm willing to send my code. I really want to get this working.
  7. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
    #7  
    you need to bind your event handler function, otherwise 'this' is not what you want it to be.

    Mojo.Event.listen(this.controller.get('amountSpent'), Mojo.Event.propertyChange, this.amountSpentChanged.bind(this));
    neathings - neat·things and apps for webOS
  8.    #8  
    Quote Originally Posted by pomokey View Post
    you need to bind your event handler function, otherwise 'this' is not what you want it to be.

    Mojo.Event.listen(this.controller.get('amountSpent'), Mojo.Event.propertyChange, this.amountSpentChanged.bind(this));
    I have done that and it has fixed some of the issues. Here is the next one:

    I have checked the log and I am getting this value:

    Uncaught TypeError: Object #<an HTMLDivElement> has no method 'getValue'

    I am running this code:
    Code:
    this.totalPlusTip = this.controller.get('tipPercentage').getValue();
    I am looking here:

    Mojo.Widget.TextField - Palm Developer Center

    And it says there is a getValue method that I should be able to call
  9. pomokey's Avatar
    Posts
    526 Posts
    Global Posts
    540 Global Posts
    #9  
    2 options, either use the this.[widgets model name here].value instead (like someone mentioned above)

    Or, correctly call getValue.
    this.controller.get('tipPercentage').mojo.getValue();
    neathings - neat·things and apps for webOS
  10. #10  
    Found this:

    webOS Text Field Widget « Steven Ramkumar

    Explains very nicely.

Posting Permissions