Add API to Polymer web component -
i building polymer web component should respond mouse/touch events. bind on-tap="{{$.myelement.show}}"
show
function in element:
show: function(e) { // event here }
is there anyway define public api in polymer. route going @ moment have attributes="event"
on element parent element has on-tap="{{updateevent}}"
:
updateevent: function(e) { this.$.myelement.event = e; }
the element has:
eventchanged: function() { show(this.event); }
which seems boilerplaty (think made word). can add show
function element prototype somehow?
if show()
method on element, use on-tap="{{show}}"
. show()
part of element's public api.
but looks want call element's method? came in pull request: https://github.com/polymer/polymer-dev/pull/30
what have setting this.$.myelement.event = e;
, using eventchanged()
in myelement
works. can call element's method directly:
updateevent: function(e) { this.$.myelement.show(); }
here few other ways: http://jsbin.com/guyiritu/1/edit
Comments
Post a Comment