2016-12-19 8 views
1

インスペクタdisplayNameに何かを書き込むときにテキストを編集して、すべての要素の受信ボックス名に渡したいと思います。 enter image description hereインスペクタをコピーするにはjointJS-Rappid内の要素ボックス内でテキスト値を編集する方法

私のjavascriptのコードは以下の通りです:

var count = 0; 
//Code to edit element inboxName with value given from displayName field 
       cell.on('change:wi_displayName', function(cell, change, opt) { 

        if(count == 0){ 
        //Do nothing the 1st time 
        } 
        else { 
         var inboxName = cell.get('wi_displayName'); 
         cell.set(cell.attr('text/text'), inboxName); 

        } 
        count++; 

       }) 
//End of code to edit element inboxName with value given from displayName field 

が、問題が最終ラインである:私は値を設定する必要がありますどのように

cell.set(cell.attr('text/text'), inboxName); 

?この要素の

マイステンシルJSONは次のとおりです。

new joint.shapes.basic.Circle({ 
      size: { width: 5, height: 3 }, 
      attrs: { 
       circle: { width: 50, height: 30, fill: '#000000' }, 
       text: { text: 'START', fill: '#ffffff', 'font-size': 10, stroke: '#000000', 'stroke-width': 0 } 
      } 
     }) 

はあなたがcell.attr('text/text', inboxName)であなたのbasic.Circle要素にテキスト属性を設定することができますあなたの

答えて

3

ありがとうございます。 attr()メソッドは、attrsオブジェクトの属性へのパスである最初の引数としてパスをとります。 cell.attr('text/text', 'MY VALUE')cell.prop('attrs/text/text', 'MY VALUE')に相当します。

cell.set()は、トップレベルのプロパティを設定するためにのみ使用できます。したがって、cell.set('attrs', { text: { text: 'MY VALUE' } })を実行する必要がありますが、他の属性(場合によってはcircleなど)が上書きされます。

+0

もちろん、もう一度@daveを実行しました。どうもありがとうございます! –

関連する問題