Binding to e.g. <input value=""> in 0.8

90 views
Skip to first unread message

Michael Bleigh

unread,
Mar 28, 2015, 5:09:55 PM3/28/15
to polym...@googlegroups.com
I started trying to port firebase-element to 0.8 and got stuck on simple two-way binding to input values. Is two-way binding only supported via custom elements in 0.8? How would I do the equivalent of this in 0.5:

<firebase-element location="https://example.firebaseio.com/demo" data="{{data}}"></firebase-element>

<input value="{{data.name}}">

Or, if that ought to work properly can you take a look at this example and tell me what's wrong with it?

Cheers,
Michael Bleigh

Michael Bleigh

unread,
Mar 28, 2015, 5:11:22 PM3/28/15
to polym...@googlegroups.com

Aleks Totic

unread,
Mar 29, 2015, 12:35:34 AM3/29/15
to polym...@googlegroups.com
firebase port is not straightforward. Firebase-element uses observers to detect changes for auto-save, and the observers are not used in 0.8. I would not start porting until I fully understand 0.8 data flow.

As for your question:

In 0.5, property binding used observers. Which was lovely, the model and the editor did not need to know anything about each other, everything just worked
In 0.8, property binding is implemented using custom events to broadcast poperty changes. Native tags like <input> do not broadcast these custom events. So, you'd have to do something like this:

<input on-change='handleChange'>

handleChange: function() {
    firebaseElement.setPath('data.name', this.$.input.value);
}

Which is a lot more verbose than it used to be. This area is still in a lot of flux.

Aleks


On Saturday, March 28, 2015 at 2:09:55 PM UTC-7, Michael Bleigh wrote:

Justin Fagnani

unread,
Mar 30, 2015, 3:21:30 AM3/30/15
to Aleks Totic, polymer-dev
Hi Michael,

There's a branch of 0.8 where work is being done to let you specify an event that will trigger an update of a binding. This will let you make two-way bindings to native elements, and custom elements that don't follow Polymer's event firing and naming conventions.

I'm not 100% sure, but I think the syntax right now looks like this:

<input value="{{data.name::change}}">

where the "::change" part basically means "on 'change' events, read the 'value' property and write it to the binding"

Not sure when this will land in 0.8, probably soon. You can file an issue and we'll notify it when it's in.

Cheers!
  Justin




Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/2c34bd26-f6b0-4fa7-a6d3-219694f4392b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages