Polymer iron-ajax element params with databinding is splitting the parameter into single chars

Sosian

I have a problem with Polymers iron-ajax element. When calling it like this:

 <iron-ajax url="https://api.onedrive.com/v1.0/drive/root" params='{"access_token":"[[access_token]]"}'></iron-ajax>

It sends a url like this, splitting the whole params string into multiple parameters:

https://api.onedrive.com/v1.0/drive/root?0="&1=a&2=c&3=c&4=e&5=s&6=s&7=_&8=t&9=o&10=k&11=e&12=n&13="...

When using a normal String as parameter it works correctly so i guess the quotes are correct.

The script part of the Element which uses iron-ajax:

<script>

  Polymer({
  is: 'onedrive-files',
  properties: {
    access_token: String
  },

  ready: function() {
  },
});
</script>

and i am calling the element like this:

<onedrive-files access_token="testtoken">
</onedrive-files>

Does anyone have any ideas? Thanks!

Edit: With an getter Function:

    <dom-module id="onedrive-files">
      <template>
    <iron-ajax id="ajax" url="https://api.onedrive.com/v1.0/drive/root" last-response="{{data}}" params='{{_getParams()}}' auto></iron-ajax>
  </template>
   <script>
     Polymer({
      is: 'onedrive-files',
      properties: {
        access_token: String
      },

      _getParams: function()
      {
        return ('{"access_token":"' + this.access_token + '"}');
      },

      ready: function() {
        this.$.ajax.generateRequest();    
    },
    });

    </script> 
    </dom-module>

With setting the Param in the Ready function:

<dom-module id="onedrive-files">
  <template>
    <iron-ajax id="ajax" url="https://api.onedrive.com/v1.0/drive/root" last-response="{{data}}" auto></iron-ajax>
  </template>

  <script>

    Polymer({
      is: 'onedrive-files',
      properties: {
        access_token: String
      },

      ready: function() {
        this.$.ajax.params = '{"access_token":"' + this.access_token + '"}';
    },
    });

  </script>
</dom-module>
Compufreak

It seems like this is another limitation of dynamic attributes. So, the usual fallback for such cases are getter functions :

 <iron-ajax url="https://api.onedrive.com/v1.0/drive/root" params='{{_getParams(access_token)}}'></iron-ajax>

...

<script>

  Polymer({
  is: 'onedrive-files',
  properties: {
    access_token: String
  },
  _getParams:function(access_token) {
       return {access_token:access_token};
  }
});
</script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Polymer iron-ajax not working

From Dev

Using Polymer iron-ajax in repeating template

From Dev

Setting callback on Polymer iron-ajax

From Dev

Trigger polymer iron-ajax request manually

From Dev

Polymer iron-ajax interval calls

From Dev

Notification via iron-ajax (Polymer)

From Dev

Polymer iron-select fires on element load

From Dev

Polymer - Choosing an Iron-Collapse element

From Dev

Polymer - Choosing an Iron-Collapse element

From Dev

Polymer iron-ajax/iron-request won't fire

From Dev

How to remove databinding of a single attribute of an element dynamically?

From Dev

Polymer 1.0: Wait for multiple iron-ajax requests to finish

From Dev

Polymer how to bind paper-input value to iron-ajax

From Dev

iron-ajax (Polymer 1.0) on-response event firing twice

From Dev

Polymer iron-ajax data binding example not working

From Dev

Polymer 1.0 <iron-ajax> inside of a dom-repeat

From Dev

Testing polymer 1.0 components with iron-ajax using wct

From Dev

Polymer dom-repeat and displaying result of iron-ajax call

From Dev

Polymer 1.0's iron-ajax passes nothing to script

From Dev

Testing polymer 1.0 components with iron-ajax using wct

From Dev

Cannot access Google Rest APIs with Iron-ajax in polymer

From Dev

Store returned values from the iron-ajax request in variables (Polymer)

From Dev

Polymer iron-ajax detail.response is null

From Dev

Polymer - iron-ajax - google sheets JSON data binding

From Dev

Google Polymer - Pass data from iron-list to custom element

From Dev

How to get model for element in iron-list (polymer dart)?

From Dev

Polymer dynamically created element not working (iron-scroll-threshold)

From Dev

How to change src of an iron-image element of Google Polymer

From Dev

Polymer iron-media-query not working on dom-repeat element

Related Related

  1. 1

    Polymer iron-ajax not working

  2. 2

    Using Polymer iron-ajax in repeating template

  3. 3

    Setting callback on Polymer iron-ajax

  4. 4

    Trigger polymer iron-ajax request manually

  5. 5

    Polymer iron-ajax interval calls

  6. 6

    Notification via iron-ajax (Polymer)

  7. 7

    Polymer iron-select fires on element load

  8. 8

    Polymer - Choosing an Iron-Collapse element

  9. 9

    Polymer - Choosing an Iron-Collapse element

  10. 10

    Polymer iron-ajax/iron-request won't fire

  11. 11

    How to remove databinding of a single attribute of an element dynamically?

  12. 12

    Polymer 1.0: Wait for multiple iron-ajax requests to finish

  13. 13

    Polymer how to bind paper-input value to iron-ajax

  14. 14

    iron-ajax (Polymer 1.0) on-response event firing twice

  15. 15

    Polymer iron-ajax data binding example not working

  16. 16

    Polymer 1.0 <iron-ajax> inside of a dom-repeat

  17. 17

    Testing polymer 1.0 components with iron-ajax using wct

  18. 18

    Polymer dom-repeat and displaying result of iron-ajax call

  19. 19

    Polymer 1.0's iron-ajax passes nothing to script

  20. 20

    Testing polymer 1.0 components with iron-ajax using wct

  21. 21

    Cannot access Google Rest APIs with Iron-ajax in polymer

  22. 22

    Store returned values from the iron-ajax request in variables (Polymer)

  23. 23

    Polymer iron-ajax detail.response is null

  24. 24

    Polymer - iron-ajax - google sheets JSON data binding

  25. 25

    Google Polymer - Pass data from iron-list to custom element

  26. 26

    How to get model for element in iron-list (polymer dart)?

  27. 27

    Polymer dynamically created element not working (iron-scroll-threshold)

  28. 28

    How to change src of an iron-image element of Google Polymer

  29. 29

    Polymer iron-media-query not working on dom-repeat element

HotTag

Archive