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 using Javascript #3420

Closed
stefanoantonel opened this issue Feb 13, 2016 · 5 comments
Closed

Data binding using Javascript #3420

stefanoantonel opened this issue Feb 13, 2016 · 5 comments

Comments

@stefanoantonel
Copy link

Hi guys!!!
I'm trying to create an instance of service-detail element with javascript inside service-section element.
I've already imported service-detail in elements.html.
For example:
In service-section element:

showDetails: function(e) {
   var detail = document.createElement('service-detail');
   detail.lang = this.lang;
   detail.services = this.services;
}

The problem is that if the property lang in service-section changes, this change is not propagated to the service-detail element.

On the other hand, if I use inside the service-section element the tag:

<service-detail lang="{{lang}}" services="{{services}}"></service-detail>

When I change the value of the lang in service-section it also change in the service-detail . (As it's suppose to work).

Now the question is, How can I do to bind properties using Javascript and creating the elements dynamically?

Thank you everyone for do the best!

@stefanoantonel stefanoantonel changed the title Data binding with Javascript doesn't work properly Data binding using Javascript Feb 13, 2016
@bedeoverend
Copy link

Hey @stefanoantonel, looks like this might be a duplicate of #1796 and #2638? Those discussions might give you an idea of where imperative data binding is at.

@dfreedm
Copy link
Member

dfreedm commented Feb 20, 2016

@bedeoverend agreed, seems like a dupe of #1796 or #2368, which need to be deduped together at some point.

@kaste
Copy link
Contributor

kaste commented Feb 23, 2016

I proposed #3460. I used something like this and if I did not messed up the PR this enables something like this:

showDetails: function(e) {
   var detail = document.createElement('service-detail');
   this.addCustomEffect('lang', function(path, value, oldValue) {
      detail['lang'] = value;
   };
}

@stefanoantonel
Copy link
Author

@kaste Thank you for your proposal !

@kaste
Copy link
Contributor

kaste commented Mar 1, 2016

Unfortunately the Holy Grail does not answer. 😯

stefanoantonel [email protected] schrieb am Di., 1. März 2016
14:37:

@kaste https://github.com/kaste Thank you for your proposal !


Reply to this email directly or view it on GitHub
#3420 (comment).

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

Successfully merging a pull request may close this issue.

4 participants