Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data binding with JavaScript no longer available in 1.0 #1796

Closed
arodic opened this issue Jun 9, 2015 · 14 comments
Closed

Data binding with JavaScript no longer available in 1.0 #1796

arodic opened this issue Jun 9, 2015 · 14 comments

Comments

@arodic
Copy link

arodic commented Jun 9, 2015

In 0.5 there was a handy built-in function this.bindProperty() as well as this.bind() It appears that equivalent functions no longer exist in 1.0. Perhaps this functionality is provided in undocumented Polymer.Bind but without documentation it is hard to tell.

@zerodevx
Copy link

zerodevx commented Jun 9, 2015

I think imperative data-binding is not supported in 1.0 per #1778

@arodic
Copy link
Author

arodic commented Jun 9, 2015

we don't currently support this

According to @kevinpschaaf this is "currently" not supported. Perhaps it will be supported in the future?

@zerodevx
Copy link

zerodevx commented Jun 9, 2015

Not sure... But given that data is bounded on registration, I'm experimenting with a (bit hackish) way to data bind imperatively by defining the prototype chain before registration on the fly. Will post results.

On 9 June 2015 15:53:42 GMT+08:00, AKI RODIC [email protected] wrote:

we don't currently support this

According to @kevinpschaaf this is "currently" not supported. Perhaps
it will be supported in the future?


Reply to this email directly or view it on GitHub:
#1796 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@JasonFitz
Copy link

Has there been any work on this? Our app hinges on the ability to bind properties to elements created dynamically.

@polpo
Copy link

polpo commented Oct 8, 2015

We also use this heavily and would like to know if any work or decisions have been made on this.

@bedeoverend
Copy link

Would also love to see this implemented +1

1 similar comment
@RobinLinus
Copy link

Would also love to see this implemented +1

@saurshaz
Copy link

saurshaz commented Dec 2, 2015

+1
repeating @polpo "We also use this heavily and would like to know if any work or decisions have been made on this."

@zerodevx
Copy link

zerodevx commented Dec 2, 2015

I believe this feature is in the Polymer owners' radar and inside the dev timeline. For certain instances, a (somewhat hackish) workaround that I used to employ was this: #2131 (comment).

Later, I just made some workflow (and mindset) changes that for most times replaced the need for late binding completely. I'll suggest that, or waiting for an official (and true) late-binding API to be released.

@warpech
Copy link

warpech commented Feb 10, 2016

I also have a problem with this: I have two Polymer elements which ignore that they are bound to the same object: https://jsfiddle.net/warpech/g4xoqaff/3/

I know that this can be worked around by wrapping them in a single Polymer element, but can't have that workaround. I would like to use a JS API to bind them together.

@devinivy
Copy link

@warpech this is possible with a little extra glue– you need to keep track of which components share that object then notifyPath() on each of them when one of them changes it. See the approach in yarn-state-behavior. And perhaps a better/simpler option in this case is to create a third element to house the shared object. This third element could be included in all elements that need to bind to the object.

Also related to this discussion are the existing linkPaths() and unlinkPaths() methods:

/**
* Aliases one data path as another, such that path notifications from one
* are routed to the other.
*
* @method linkPaths
* @param {string} to Target path to link.
* @param {string} from Source path to link.
*/
linkPaths: function(to, from) {
this._boundPaths = this._boundPaths || {};
if (from) {
this._boundPaths[to] = from;
// this.set(to, this._get(from));
} else {
this.unlinkPaths(to);
// this.set(to, from);
}
},
/**
* Removes a data path alias previously established with `linkPaths`.
*
* Note, the path to unlink should be the target (`to`) used when
* linking the paths.
*
* @method unlinkPaths
* @param {string} path Target path to unlink.
*/
unlinkPaths: function(path) {
if (this._boundPaths) {
delete this._boundPaths[path];
}
},

@kaste
Copy link
Contributor

kaste commented Mar 4, 2016

Can you take a look at #3456 (and its related PR #3460) and perhaps comment if that would fix your issue.

@tjsavage tjsavage added the 1.x label Sep 8, 2016
@TimvdLippe
Copy link
Contributor

Closing per #3460 (comment) This API shipped in Polymer 2.

@dman777
Copy link

dman777 commented Apr 17, 2018

👎 What about Polymer 1.*? It is still being supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.