dynamically pass in a template to a polymer-element

479 views
Skip to first unread message

august black

unread,
Aug 5, 2014, 6:49:17 PM8/5/14
to polym...@googlegroups.com
Hi,

I have been trying to do the following using a variety of techniques in polymer.

What I want do is create a polymer-element that generates a list based on an ajax request, but that also .
It's basically a polymer rebuild of the 'select2' library for autocompletion.

So, the base template I have so far looks like this:

<polymer-element name="auto-complete" attributes="url_base item_template">
<aj-ax id="xhr" url="{{url_base}}" params="{}" handle_as="json" on-ajax-response="{{handle_res}}" on-ajax-error="{{handle_err}}"></aj-ax>
    <input id="eingabe" type="text" on-keyup="{{process_request}}" on-blur="{{hide_dropdown}}"/>
    <div id="dropdown" hidden?="{{hide}}">
      <ul>
        <template repeat="{{i in items}}">
          <li> i.text 
             <!--
                   the above works, but I want to make it more generic so that you can pass in a template that reads the item model such as
                   <template ref="{{item_template}}" bind="bind"></template> 
                   where item_template is in some outside scope
              -->
          </li>
        </template>
      </ul>
</polymer-element >
    </div>


I've also tried to make a base auto-complete.html polymer-element and then extend it based on the auto-complete type...but to no avail.


Any thoughts, ideas?

I want to stick to declarative methods if possible and avoid having to build the DOM elements myself with document.createElement
Is that even possible?

thanks, best -august.

Steve Orvell

unread,
Aug 14, 2014, 6:24:07 PM8/14/14
to august black, polym...@googlegroups.com
You might take a peek at the `core-list` element (https://github.com/Polymer/core-list/blob/master/core-list.html#L23). It accepts a template and uses it to create list items.


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/0cb13177-d160-4062-a1d3-dba003899f96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages