Or use injectBoundHTML
this.injectBoundHTML('<div
on-click="{{clickOnDynamicllyElement}}">dynamicllyElement</div>', this.$.modal);
среда, 29 октября 2014 г., 11:32:05 UTC+3 пользователь Антон Мирошниченко
написал:
>
> Thanks for your answer. I think need change understanding of polymer
> solutions. They should not be similar to "old javascript" application.
>
> среда, 29 октября 2014 г., 11:07:53 UTC+3 пользователь David Waterman
> написал:
>>
>> Is there something about the template solution that is insufficient
>> compared to what you're trying to do?
>>
>> You can imagine why it might be that what you're trying won't work,
>> right? You're trying to add an attribute with moustache binding, but they
>> are surely only evaluated and bound when the Polymer element is
>> constructed. To do the same thing, you'd quite likely have to invoke some
>> of the polymer internals to process the element you're adding, after it has
>> been added.
>>
>> I suppose there might be a way to do this 'correctly', but I don't know
>> it and no one else is answering so I imagine it is not possible. It's
>> certainly not 'the polyer way' as I see it - I mean the moustache binding
>> is, but dynamically adding such an attribute isn't something I've seen
>> before.
>>
>> I would have done it something like this :
>>
>> <template bind if="{{ showModal }}">
>> <div on-click="{{clickOnDynamicllyElement}} style="top:{{modalTop}};
>> left:{{modalLeft}}">dynamicllyElement</div>
>> </template>
>> ...
>> created: function() {
>> this.showModal = false;
>> this.modalTop = '0px';
>> this.modalLeft = '0px';
>> }
>> showMdl: function(e,detail,sender){
>> this.modalTop = e.layerY+'px';
>> this.modalLeft = e.layerX+'px';
>> this.showModal = true;
>> },
>>
>> I've not tried it though, so ymmv.
>>
>> It occurs to me that it's also possible to do things with classes eg by
>> toggling a class that has 'display: none;'
>>
>> Max.
>>
>> On Wed Oct 29 2014 at 07:52:43 Антон Мирошниченко <[email protected]>
>> wrote:
>>
>>> templates has resolved this problem. But it is not dynamically behavior,
>>> templates must be created in polyemer-element early.
>>>
>>> среда, 29 октября 2014 г., 10:39:55 UTC+3 пользователь David Waterman
>>> написал:
>>>>
>>>> I think you basically "can't do that". Perhaps you can use a template
>>>> bound to a property that is set in your showMdl function? ...along the
>>>> lines of this :
>>>>
>>>> <https://www.polymer-project.org/docs/polymer/template.html#if>
>>>>
>>> On Wed Oct 29 2014 at 07:18:06 Антон Мирошниченко <[email protected]>
>>>> wrote:
>>>>
>>> Thanks. But i suppose it is not polymer way. Meaby my question is not
>>>>> correct. What if i need data-binding for a new element?
>>>>>
>>>>> среда, 29 октября 2014 г., 1:42:09 UTC+3 пользователь Claudius Nicolae
>>>>> написал:
>>>>>
>>>>>> newElement.addEventListener('click', this.clickOnDynamicllyElement);
>>>>>>
>>>>>> learn js and dom
>>>>>>
>>>>> 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 [email protected].
>>>>
>>>>
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/polymer-dev/d39e75e3-65a1-4637-837c-f3ece533acb7%
>>>>> 40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/polymer-dev/d39e75e3-65a1-4637-837c-f3ece533acb7%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/polymer-dev/b48b3b1c-0179-402b-9742-195fafca0d0a%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/polymer-dev/b48b3b1c-0179-402b-9742-195fafca0d0a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/4223c41b-b542-4ec0-88ac-88155316c807%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.