I added an event listener to my user element for my call to <iron-ajax> .
Question
Is there a shorter (more convenient syntax) way to strongly (i.e. using Javascript) add an event listener to Polymer?
In other words, does the Polymer library contain any syntactic sugar for this?
order element.html
<template> ... <iron-ajax id="ajax" last-response="{{ajax}}"></iron-ajax> ... <template> <script> ... var that = this, t = this.$.ajax; t.addEventListener('response', function(e) { console.log(that.ajax); }); ... </script>
Study
The documentation here says:
You can also add an event listener to any element of the this.$ Collection using nodeId.eventName syntax.
But I think this only applies when using the listeners property in a Polymer object, as in:
listeners: { 'tap': 'regularTap', 'special.tap': 'specialTap' },
source share