Results 1 to 5 of 5
  1.    #1  
    Hey guys, I'm building a small app that takes data from a user form and submits it to another server, just like an HTML form with a POST action.

    So one of my widgets is a List Selector (drop down box) so the user can pick between several options. I'm trying to determine what the value of the selector is so I can POST it. Maybe I'm going about this wrong, but for my button handler (submit button), I'm doing the following:

    Code:
    FirstAssistant.prototype.handleButtonPress = function(event){
    	var month = this.dateModel['date'].getMonth();
    	var day = this.dateModel['date'].getDate();
    	var date = this.dateModel['date'].getFullYear();
    	var description = this.controller.get("description").mojo.getValue();
    	var category = this.controller.get("category").mojo.getValue();
    	Mojo.Log.error(category);
    };
    I'm testing this phase of the code, so for now I'm just sending the value of the widget to the log file. Getting the value of the other widgets is working fine.

    So the bold widget above, called category is my List Selector and I just need to be able to see what the user selected. I see in the API that it has an event, but I'm not sure if I should use that with a submit form, or how?

    Thanks!

    David
  2. moserjj's Avatar
    Posts
    468 Posts
    Global Posts
    470 Global Posts
    #2  
    how is your listSelector setup? you need to get the value from the model assigned when you setup the widget
  3.    #3  
    I think that's what I'm missing and I wasn't sure how to setup the model for this widget:

    Code:
        this.controller.setupWidget("category",
            this.attributes = {
    			label: "Cagegory",
                choices: [
    				{label: "One", value: "1"},
    				{label: "Two", value: "2"}
                ]},
            this.model = {}
        );
  4. moserjj's Avatar
    Posts
    468 Posts
    Global Posts
    470 Global Posts
    #4  
    I would try setting up your list widget like this

    Code:
        this.categoryAttributes = {
    			label: "Cagegory",
                choices: [
    				{label: "One", value: "1"},
    				{label: "Two", value: "2"}
                ]
    	};
    	
    	this.categoryModel = { value: "1"};
    	
    	this.controller.setupWidget("category", this.categoryAttributes, this.categoryModel);
    then you can access the value of the list widget with

    Code:
    this.categoryModel.value
  5.    #5  
    That did it! Thanks!

Posting Permissions