Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

I thought change to an input text box in view can reflect back to the can.Observe?

$
0
0
I thought I saw in http://www.infoq.com/presentations/CanJS that we can bind "both way" from an input text box in a view, to and from a can.Observe ?

But somehow the following won't work:


  1. <script type='text/ejs' id='template'>
  2.     
  3.   <input type="text" value="<%= foo.attr('bar') %>">

  4. </script>

  5. <script>
  6. var foo = new can.Observe({ bar: "hello" });

  7. var template = can.view("#template", {
  8.     foo: foo
  9. });
  10. $(document.body).prepend(template);

  11. </script>

the jsfiddle link will give a demo of the value of the can.Observe vs the input's value... somehow if a user types something in, it is not reflected in the can.Observe?   And is using EJS the only way to make two-way work?  Can Mustache be used to do it -- if somebody can make it work and give an example in the jsfiddle?



Viewing all articles
Browse latest Browse all 3491

Trending Articles