Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass an attribute to a core-ajax in an element definition?

Tags:

ajax

polymer

I am creating an element, which takes one parameter: userid. Inside the component's template I have a core-ajax tag which needs to pass that attribute as a parameter.

I am doing it like this:

<template attributes="userid">
    <core-ajax
        auto
        url="../../ajax/gettoday.php" 
        handleAs="json" 
        method="post" 
        params='{"userid": "{{userid}}"}'
        response="{{today}}"></core-ajax>
        ...
</template>

Is it supposed to accept the attribute inside the params string?

like image 676
user2430829 Avatar asked Dec 12 '25 10:12

user2430829


1 Answers

The attributes="userid" needs to be on the <polymer-element>, not the element's <template>. Nothing should go on the topmost <template>.

<polymer-element name="my-element" attributes="userid">

This works for me: http://jsbin.com/fihuyuga/1/edit

like image 126
ebidel Avatar answered Dec 13 '25 23:12

ebidel