聚合物如何从事件处理程序范围设置元素的属性

时间:2016-10-20 09:57:09

标签: javascript polymer polymer-1.0

我无法从第三方lib(fabricjs)的事件处理程序中弄清楚如何在我的聚合物元素上.set()属性。例如:

<dom-module id="x-example">
  <template>
    <div id="objectTools" hidden$="{{objectToolsHidden}}">
      <h1> object toolz!</h1>
    </div>
    <canvas id="c" width="400" height="400"></canvas>
  </template>
  <script>
  Polymer({
    is: 'x-example',
    properties: {
      canvas: Object,
      objectToolsHidden: {
        type: Boolean,
        notify: true,
        value: true
      }
    },
    _onObjectSelected: function(e){
        //hmm, this is the canvas elem... (???)
        this.set('objectToolsHidden', false);
    },
    _onSelectionCleared: function(e){
        this.set('objectToolsHidden', true);
    },
    ready: function(){
      this.canvas = new fabric.Canvas(this.$.c);
      var rect = new fabric.Rect({
          top : 100,
          left : 100,
          width : 60,
          height : 70,
          fill : 'black'
      });

      this.canvas.add(rect);

      this.canvas.on({
       'object:selected': this._onObjectSelected,
       'selection:cleared': this._onSelectionCleared
      });
    }
  });
  </script>
</dom-module>

...方法_onObjectSelected被调用,但this.set()未被定义为函数。如何从范围事件处理程序中访问我的元素属性?

还有一个jsfiddle:http://jsfiddle.net/ysoo8mjg/

1 个答案:

答案 0 :(得分:0)

哦!!我可以在事件处理程序注册中使用job_id client_name shop_name job_text job_code 1 client1 shop1 job txt 0178923 2 client2 shop2 "job2 txt 67676 job2-txt job2_txt" 3 client3 shop3 job3 txt 7878

 gawk -F\\t 'BEGIN{OFS="\t";}{ print $1,$2,$3,$4,$5;}' downloads/download.csv > common.csv

building your image from a Dockerfile