use core-collapse with core-ajax inside a template

118 views
Skip to first unread message

Jeremy Odekirk

unread,
Feb 17, 2015, 5:19:52 PM2/17/15
to polym...@googlegroups.com
The demo of core-collapse is too simplistic. How do you use core-collapse without specifying a unique id?

I have an auto binding template that gets a list of documents returned by core-ajax. After it returns the list I want to have the option of expanding any of the items by clicking a plus icon or using core-collapse.

How do you use core-collapse to expand the current clicked row of data without specifying an id?

When the item is clicked, I want to run core-ajax to get the insides of the item and then display them.

Rob Dodson

unread,
Feb 18, 2015, 11:18:57 AM2/18/15
to Jeremy Odekirk, polymer-dev
Depending on how you set things up, you could listen for the anchor clicks and then use JavaScript to find the nearest core-collapse, or turn the whole thing into its own element so the plus symbol always is paired with one core-collapse and it knows exactly who to open.

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 polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/a62d706b-cdb6-4028-bf32-f81f4f9d4515%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeremy Odekirk

unread,
Feb 19, 2015, 10:09:34 AM2/19/15
to polym...@googlegroups.com, jode...@gmail.com
Thanks, I would love to do this with as little JavaScript as possible since that is the main reason I am trying to convert my web app to using Polymer. Is there any code example that would explain how to do this?  How would I turn the whole thing into its own element so the plus symbol always is paired with one core-collapse and it knows exactly who to open?

Rob Dodson

unread,
Feb 20, 2015, 5:08:05 PM2/20/15
to Jeremy Odekirk, polymer-dev

Jeremy Odekirk

unread,
Feb 24, 2015, 3:50:49 PM2/24/15
to polym...@googlegroups.com, jode...@gmail.com
Thanks. Your example of core-collapse helped me figure out how to use multiple core-collapses without IDs.
Now the tricky part I still don't understand is how do we use core-ajax inside the core-collapse?
I want core-ajax to only fire when I click the Plus sign to expand the core-collapse. Then it does an ajax call and displays the results inside the clicked core-collapse. How do I do this without specifying IDs so it works when there are potentially thousands of core-collapses on the page?

I was trying to add the polymer core-ajax demo code to my code and this is as far as I got:
Reply all
Reply to author
Forward
0 new messages