-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Nodes do not appear in this.$ when they become visible after a <template if=""> condition has been met. #642
Comments
I just wanted to file this issue also. |
This is a great source of frustration for many folks that I'd love to see use support it someday. |
I've ended up adding the following myself:
Which then allows me to do Without jQuery, you could probably do:
Just as a shorthand. |
I acknowledge that this is a stumbling block for many users, unfortunately it's not so easy to fix.
Also note that |
An example of using $ in a conditional template is getting the value of the
|
Also, there is the question of whether there is value in the text box being in a conditional template instead of being modulated via |
(I had the same issue: http://stackoverflow.com/questions/25651295/html-elements-wrapped-with-a-condition-are-null-in-when-my-polymer-element-calls.) So, several anti-patterns and bad ideas are mentioned here, but if not template if conditionals, are there some docs or a full fledged code sample of the proper pattern? Some best practices would go a long way. |
There's discussion in this section: http://www.polymer-project.org/docs/polymer/polymer.html#automatic-node-finding |
Yes, but that seems pretty hacky. Best practices are what I'm after, rather than forcefully doing it the way I want to. Do you think my answer posted on SO is a better approach? http://stackoverflow.com/questions/25651295/html-elements-wrapped-with-a-condition-are-null-in-when-my-polymer-element-calls/25653991#25653991 |
Why hacky? It's utilizing a built-in Polymer feature and avoids the pitfalls of using |
Sorry, I don't think I quite got it the first time. So in that example, you're surrounding the template conditional with a node that will be added to $, thereby giving a means to access the stuff inside the template conditional that wasn't there when $ was populated. I like it. And so I fully understand, what are those pitfalls "when the element is extending another"? Thanks so much. This is great fundamental stuff. Your docs are comprehensive, but a lot of is tough to grasp for less advanced developers like myself, I think. Some kind of "you want to do this, therefore know these concepts" approach might help, where here it's like an index of concepts and I'm not sure what's relevant to my case. Thank you! |
I have a somewhat similar issue so I'm going to add to this one, feel free to open a new issue if it's not related. Here is the stackoverflow and the jsfiddle |
As described in googlearchive/TemplateBinding#205, "automatic node finding" actually works in a conditional template if the condition is true the first time the template is rendered. |
Closing this issue due to age and the release of version 1 of Polymer - please feel free to re-open if this is incorrect. |
plz give me one example |
Nodes do not appear in this.$ when they become visible after a
<template if="">
condition has been met.As an example, if the element below is instantiated and at some later time element.setDone() and element.printValue() are executed sequentially, the console.log() command in printValue() fails with a null pointer dereference.
The text was updated successfully, but these errors were encountered: