2016-09-13 2 views
0

これは私がアクセスしたい"tr_name"のJSONファイルです。これはvar InspectorDefsの中にありますが、私は方法を見つけることができません。助けてください?この特定のJSONキーにアクセスするには

JSONファイル:

var InspectorDefs = { 

    'link': { 

     inputs: { 
      attrs: { 
       '.attributes': { 
        'tr_name': { type: 'text', group: 'attributes', label: 'Name', index: 1 }, 
        'tr_description': { type: 'text', group: 'attributes', label: 'Description', index: 2 }, 
        'tr_rules': { type: 'select', options: [], group: 'attributes', label: 'Rule', index: 3 }, 
        'tr_value': { type: 'select', options: ['true', 'false'], group: 'attributes', label: 'Value', index: 4 }, 
        'tr_rule_source': { type: 'select', options: ['BPM', 'Drools', 'iLog'], group: 'attributes', label: 'Rule source', index: 5 } 

       }, 
      }, 
     }, 
    }, 



}; 

私はここtr_nameパスを渡したいが、私は必死だ:

cell.on('change:tr_name', function(cell, change, opt) {}) 

答えて

1

あなただけのJavaScriptであなたのプロパティにアクセスする方法を探しているならば、あなたが参照しますこのように

InspectorDefs.link.inputs.attrs[".attributes"].tr_description 

JSONオブジェクトはプロパティまたはdicとして参照できます私はあなたが ".attributes"に問題があると仮定していますか?

JsFiddle

+1

あなたはtr_description 。私はまだcell.on( 'change:tr_description'、function(cell、change、opt){})の実装には問題がありますが、あなたが私の質問に答えても関係なく、最終的な答え。 –

+1

これは100%動作します。ありがとうございました !!! –

1

あなたは、配列やマップのように[]を使用することができます。

var tr_name = InspectorDefs['link']['inputs']['attrs']['.attributes']['tr_name']; 

あなたのケースでは、いくつかのhtmlタグの属性が変更されたときにいくつかの関数を呼び出すと思います。このjsonファイルによって生成された実際のhtmlタグは、生成されたWebページから、または私の推測から見つけることができます:<Name> jsonファイルから読み取ったタグ

+0

私を助けてくれてありがとうが、私のproblem.Nowを見つけたそれは素晴らしい作品です。 –

関連する問題