textarea widget - data binding not working?

50 views
Skip to first unread message

sfinnie

unread,
Jan 18, 2013, 11:46:22 AM1/18/13
to mo...@googlegroups.com
Hi Folks

Discovered that using my 'textarea' control, data values aren't persisted.  It appears the databind isn't working.

mobl code as follows:

control textArea(    s : String, placeholder : String = null,
                    label : String = null,
                    rows: String = "10", cols: String="50",
                    style : Style = textAreaStyle,
                    onchange : Callback = null, onkeyup : Callback = null) {

  when(label) {
    mobl::label(label, style=textFieldLabelStyle)
  }
  <textArea rows=rows cols=cols class=style placeholder=placeholder databind=s onchange=onchange onkeyup=onkeyup onblur={ scrollUp(); }/>
}

If I look in the dev console the insert statement is:

INSERT INTO `domainModel__Complaint` (`complainant`, `description`, `dateCreated`, `open`, id) VALUES (?, ?, ?, ?, ?) ["A N Other", "", 1358519452, 0, "3CA5B33DB0A241EC8D75CBADED11C96B"]

The value in the textarea control isn't being bound for some reason. If I change 'textArea' for 'input' it all works as expected:


  <input type="text" class=style placeholder=placeholder databind=s onchange=onchange onkeyup=onkeyup onblur={ scrollUp(); }/>

INSERT INTO `domainModel__Complaint` (`complainant`, `description`, `dateCreated`, `open`, id) VALUES (?, ?, ?, ?, ?) ["A N Other", "A Complaint", 1358519452, 0, "3CA5B33DB0A241EC8D75CBADED11C96B"]

Any suggestions?

Thanks,
Scott.

sfinnie

unread,
Jan 21, 2013, 8:13:58 AM1/21/13
to mo...@googlegroups.com
Ok did some digging.  Created two simple controls as follows:

control minTextArea( s: String) {
    <textArea databind=s />
}

control minTextField (s: String) {
    <input type="text" databind=s />
}


The generated javascript is pretty much the same, except the minTextField has this additional code block:

  subs__.addSub(mobl.domBind(node33, 'keyup change', function() {
    ignore19 = true;
    s.set(mobl.stringTomobl__String(node33.val()));
    ignore19 = false;
  })); 

If I manually insert an analogous block into the generated minTextArea function everything works.

So next questions: why is the block not being generated for the textArea component?  Any pointers as to where I go look in the mobl source?

Thanks,
Scott.

Danny Groenewegen

unread,
Jan 21, 2013, 8:38:29 AM1/21/13
to mo...@googlegroups.com

Zef Hemel

unread,
Jan 21, 2013, 8:39:10 AM1/21/13
to mobl group

sfinnie

unread,
Jan 21, 2013, 8:52:22 AM1/21/13
to mo...@googlegroups.com
Solved - case sensitivity problem.

trans/generation/ui.str has a strategy that tests the input type (line 299).  However it checks "textarea", not "textArea".  Changing the control definition accordingly means things work.

Since html5 is not case sensitive, I guess mobl shouldn't be either?  Have raised an issue on yellowgrass (#279). 

 - S.


On Friday, January 18, 2013 4:46:22 PM UTC, sfinnie wrote:
Message has been deleted

sfinnie

unread,
Jan 21, 2013, 9:02:16 AM1/21/13
to mo...@googlegroups.com
Zef, Danny, race condition.  I was digging whilst you were posting.  Guess I learned a little bit more about mobl :-) 

Case sensitivity indeed the problem.  Thanks for the help.

 - S.
Reply all
Reply to author
Forward
0 new messages