javascript - Manually connecting and disconnecting bindings -


i'm creating form fields billing , shipping addresses. when user checks "same address", want create binding between billing address , shipping address; when box unchecked, want disconnect binding.

html:

{{#with billingaddress}}   {{view ember.textfield valuebinding="firstname"}}   {{view ember.textfield valuebinding="lastname"}} {{/with}}  {{view ember.checkbox checkedbinding="view.issameaddress"}}  {{#with shippingaddress}}   {{view ember.textfield valuebinding="firstname"}}   {{view ember.textfield valuebinding="lastname"}} {{/with}} 

javascript:

app.addressesroute = ember.route.extend({   model: function() {     return {       billingaddress: checkout.billingaddress,       shippingaddress: checkout.shippingaddress     };   } });  app.addressesview = ember.view.extend({   issameaddress: false,   usesameaddress: function() {     if (this.issameaddress) {       // bind billing , shipping addresses     } else {       // remove binding     }   }.observes('issameaddress') });  app.address = ember.object.extend({   firstname: null,   lastname: null });  app.billing = app.address.create({   firstname: 'john',   lastname: 'doe' });  app.shipping = app.address.create({   firstname: '',   lastname: '' }); 

i've tried using ember.binding, number of other methods no luck. i've been able set shipping billing, there no binding , template not update.

any or nudge in right direction appreciated!

i'm not ember expert seems need use ember.binding. maybe this:

ember.oneway(app.shipping, "firstname", "app.billing.firstname"); 

to set 1 way binding between app.shipping.firstname , app.billing.firstname fields.

http://jsfiddle.net/msxep/1/


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -