Thanks Daniel, that worked perfectly. I also added a debounce in an
observer as well, giving me perfectly what i wanted. Cheers
Thanks again!
Final code:
iron_jsonp-library
<iron-jsonp-library
library-url="[[_encodeLibraryUrl(accountId, _query)]]"
notify-event="api-load"
library-loaded="{{loaded}}">
</iron-jsonp-library>
query prop with observer
query: {
type: String,
value: '',
notify: true,
observer: '_queryChanged'
},
the observer
_queryChanged: function() {
if (this.query != '')
this.debounce('_setQuery',function() {
this._query = this.query;
}, 500);
},
the encode method
_encodeLibraryUrl: function(accountId, query) {
return "http://api.bigstockphoto.com/2/" +
encodeURIComponent(accountId) + "/search/?callback=%%callback%%&q=" +
encodeURIComponent(query);
},
Thanks again Daniel!
On Friday, December 4, 2015 at 10:19:48 PM UTC+11, Daniel Llewellyn wrote:
>
>
> > On 4 Dec 2015, at 06:57, Doug White <[email protected]
> <javascript:>> wrote:
> >
> > 1) Heres my iron-jsonp-library attempt
> >
> >
> > <iron-jsonp-library
> > library-url="
> http://api.bigstockphoto.com/2/{{accountId}}/search/?callback=%%callback%%&q={{query}}"
>
>
> > notify-event="api-load"
> > library-loaded="{{loaded}}">
> > </iron-jsonp-library>
> >
> > it appears to work fine until the query contains space characters, at
> which point I get the following error message
>
> I believe the best way to achieve this would be to use a function to
> URL-Encode the variables.
>
> <iron-jsonp-library library-url=“[[_encodeLibraryUrl(accountId,query)]]”
> .. ></iron-jsonp-library>
>
> with a supporting _encodeLibraryUrl function as follows:
>
> _encodeLibrary_url: function(accountId, query) {
> return “http://api.bigstockphoto.com/2/“ +
> encodeURIComponent(accountId) + “/search/?callback=%%callback%%&q=“ +
> encodeURIComponent(query);
> }
>
> Hope this helps.
>
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/d29dee4a-8703-4052-8b52-919b76336a01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.