Yes it works, looks like WebComponentsReady is raised after templates
applied.
Also you can try modify template content. Make it sense?
$(document).ready(function() {
var host = document.querySelector('template');
$(host.content.querySelector('div#myID')).html('donatello is the best ninja
turtle');
});
On Wednesday, 13 November 2013 05:00:26 UTC+4, Scott Miles wrote:
>
> Document-ready time is likely too early to access API on custom elements.
> You should listen for the `WebComponentsReady` event.
>
> addEventListener('WebComponentsReady', function() {
>
>
> var test = document.querySelector("gr-test");
> console.log(test);
>
> test.aMethod();
>
> });
>
>
> On Tue, Nov 12, 2013 at 4:57 PM, Scott Miles <[email protected]<javascript:>
> > wrote:
>
>> Yes you did, sorry I didn't see the code link at first.
>>
>>
>> On Tue, Nov 12, 2013 at 4:56 PM, Scott Miles <[email protected]<javascript:>
>> > wrote:
>>
>>> Did you make sure to load polymer before jquery?
>>>
>>>
>>> On Tue, Nov 12, 2013 at 4:37 PM, <[email protected] <javascript:>>wrote:
>>>
>>>> I should add that I tested without jquery (clicking a button to call
>>>> the aMethod in the custom element) and it works ok, so there's something
>>>> breaking when using jquery.
>>>>
>>>>
>>>>
>>>> On Tuesday, November 12, 2013 4:33:49 PM UTC-8, [email protected]:
>>>>>
>>>>> Hi, I'm experiencing a similar issue with jquery + polymer. The stack
>>>>> trace I get is the following:
>>>>>
>>>>> TypeError {stack: "TypeError: Object #<Object> has no method
>>>>> 'aMethod…rgeh/rhythmGeometry/libs/polymer.min.js:32:25185)"}
>>>>> "TypeError: Object #<Object> has no method 'aMethod' at
>>>>> HTMLDocument.<anonymous> (http://localhost/~jorgeh/
>>>>> rhythmGeometry/webCompTest.html:23:18<http://localhost/~jorgeh/rhythmGeometry/webCompTest.html>)
>>>>>
>>>>> at fire (http://localhost/~jorgeh/rhythmGeometry/libs/jquery-1.
>>>>> 9.1.js:1037:30<http://localhost/~jorgeh/rhythmGeometry/libs/jquery-1.9.1.js>)
>>>>>
>>>>> at Object.self.fireWith [as resolveWith] (http://localhost/~jorgeh/
>>>>> rhythmGeometry/libs/jquery-1.9.1.js:1148:7<http://localhost/~jorgeh/rhythmGeometry/libs/jquery-1.9.1.js>)
>>>>>
>>>>> at Function.jQuery.extend.ready (http://localhost/~jorgeh/
>>>>> rhythmGeometry/libs/jquery-1.9.1.js:433:13<http://localhost/~jorgeh/rhythmGeometry/libs/jquery-1.9.1.js>)
>>>>>
>>>>> at Object.completed (http://localhost/~jorgeh/
>>>>> rhythmGeometry/libs/jquery-1.9.1.js:103:11<http://localhost/~jorgeh/rhythmGeometry/libs/jquery-1.9.1.js>)
>>>>>
>>>>> at v (http://localhost/~jorgeh/rhythmGeometry/libs/polymer.
>>>>> min.js:32:26221<http://localhost/~jorgeh/rhythmGeometry/libs/polymer.min.js>)
>>>>>
>>>>> at t (http://localhost/~jorgeh/rhythmGeometry/libs/polymer.
>>>>> min.js:32:25576<http://localhost/~jorgeh/rhythmGeometry/libs/polymer.min.js>)
>>>>>
>>>>> at r (http://localhost/~jorgeh/rhythmGeometry/libs/polymer.
>>>>> min.js:32:25321<http://localhost/~jorgeh/rhythmGeometry/libs/polymer.min.js>)
>>>>>
>>>>> at q (http://localhost/~jorgeh/rhythmGeometry/libs/polymer.
>>>>> min.js:32:25185<http://localhost/~jorgeh/rhythmGeometry/libs/polymer.min.js>
>>>>> )"
>>>>>
>>>>> And here <https://gist.github.com/jorgehatccrma/7441374> you can see
>>>>> the code that generates the error. Any help is appreciated.
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>> On Wednesday, October 23, 2013 8:35:32 AM UTC-7, Erik Arvidsson wrote:
>>>>>>
>>>>>> This sounds like there is a bug in the shadow dom polyfill. However,
>>>>>> I need more information.
>>>>>>
>>>>>> A few things that might help.
>>>>>>
>>>>>> 1. Make sure you have a recent version of jQuery. DOM removed
>>>>>> getAttribute from non Element objects and it is possible that old jQuery
>>>>>> tries to get an attribute of a non element.
>>>>>> 2. Break on all errors in your debugger and check what object
>>>>>> getAttribute is being called on. If it is not an element, did you expect
>>>>>> it
>>>>>> to be an element?
>>>>>> 3. Post a repro case online for me to debug.
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>
>>>>>> On Tue, Oct 22, 2013 at 10:44 PM, Sean Lee <[email protected]> wrote:
>>>>>>
>>>>>>> I was loading polymer after jquery, but I found that I problem is
>>>>>>> actully from bootstrap.js.
>>>>>>>
>>>>>>> Now I'm loading polyer first, using requirejs to load other js
>>>>>>> library, now my order is
>>>>>>>
>>>>>>> <script src="/static/js/lib/polymer.min.js"></script>
>>>>>>> <script src="/static/js/lib/require.js"></script>
>>>>>>> <script src="/static/js/mod/common.js"></script>
>>>>>>> <script src="/static/js/app/main.js"></script>
>>>>>>>
>>>>>>> In the main.js I'm simply looking if the bootstap is load correctly.
>>>>>>>
>>>>>>> require(['jquery', 'bootstrp'], function ($, _bootstrap) {
>>>>>>> console.log($.fn.affix);
>>>>>>> });
>>>>>>>
>>>>>>> If I only load jquery, nothing is wrong. if I load bootstrap, and
>>>>>>> the console keep poping up the error
>>>>>>>
>>>>>>> TypeError {stack: "TypeError: Object #<Object> has no method
>>>>>>> 'getAttr…0.0.0:8888/static/js/lib/polymer.min.js:32:21430)"}
>>>>>>> "TypeError: Object #<Object> has no method 'getAttribute' at
>>>>>>> Function.ot.attr (http://0.0.0.0:8888/static/
>>>>>>> js/lib/jquery.min.js:4:14427<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at Array.<anonymous> (http://0.0.0.0:8888/static/
>>>>>>> js/lib/jquery.min.js:4:16241<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at
>>>>>>> http://0.0.0.0:8888/static/js/lib/jquery.min.js:4:21015<http://0.0.0.0:8888/static/js/lib/jquery.min.js>at
>>>>>>> Tt.a (
>>>>>>> http://0.0.0.0:8888/static/js/lib/jquery.min.js:4:22596<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at kt
>>>>>>> (http://0.0.0.0:8888/static/js/lib/jquery.min.js:4:23640<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at Function.ot (http://0.0.0.0:8888/static/
>>>>>>> js/lib/jquery.min.js:4:9477<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at HTMLDocument.x.event.handlers (http://0.0.0.0:8888/static/
>>>>>>> js/lib/jquery.min.js:5:10458<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at HTMLDocument.x.event.dispatch (http://0.0.0.0:8888/static/
>>>>>>> js/lib/jquery.min.js:5:9715<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at Object.y.handle (http://0.0.0.0:8888/static/
>>>>>>> js/lib/jquery.min.js:5:6789<http://0.0.0.0:8888/static/js/lib/jquery.min.js>)
>>>>>>>
>>>>>>> at v
>>>>>>> (http://0.0.0.0:8888/static/js/lib/polymer.min.js:32:21430<http://0.0.0.0:8888/static/js/lib/polymer.min.js>
>>>>>>> )"
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Oct 23, 2013 at 12:23 AM, Daniel Freedman <[email protected]
>>>>>>> > wrote:
>>>>>>>
>>>>>>>> We have some basic tests for jquery + polymer, but nothing too
>>>>>>>> involved.
>>>>>>>>
>>>>>>>> Can you share a bit more detail about what your setup? Is polymer
>>>>>>>> being loaded before jquery? The opposite order could cause a whole
>>>>>>>> host of
>>>>>>>> issues, as the Shadow Dom polyfill has to modify some DOM APIs like
>>>>>>>> queryselector to work properly.
>>>>>>>> On Oct 22, 2013 3:38 AM, "Sean Lee" <[email protected]> wrote:
>>>>>>>>
>>>>>>>>> I was using polymer with jquery, but it seems that the $ is
>>>>>>>>> causing some problem.
>>>>>>>>>
>>>>>>>>> I keep getting
>>>>>>>>>
>>>>>>>>> TypeError: Object #<Object> has no method 'getAttribute'
>>>>>>>>>
>>>>>>>>> when I click anywhere in the page.
>>>>>>>>>
>>>>>>>>> Anyone have experience using these two together?
>>>>>>>>>
>>>>>>>>> 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].
>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best regards,
>>>>>>> Sean Lee
>>>>>>>
>>>>>>> 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].
>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> erik
>>>>>>
>>>>>>
>>>>>> 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] <javascript:>.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>
>>
>
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].
For more options, visit https://groups.google.com/groups/opt_out.