2010-09-22 74 views
9
var tinymce_toolbar = {} 
tinymce_toolbar.__default = 
{ 
    script_url: '/cms/libs/js/manual/renders/tiny_mce/tiny_mce.js', 
}; 
tinymce_toolbar.__simple = 
{ 
    script_url: '/cms/libs/js/manual/renders/tiny_mce/tiny_mce_simple.js', 
}; 


// Doesn't work 
var t = $(this).find('input[name=toolbar]').first().val(); 
$('.RenderHtmlEditor').tinymce(tinymce_toolbar.t); 

// works 
var t = $(document).find('input[name=toolbar]').first().val(); 
$('.RenderHtmlEditor').tinymce(tinymce_toolbar.__default); 
$('.RenderHtmlEditor').tinymce(tinymce_toolbar.__simple); 

我該如何做到動態?謝謝在javascript中獲取動態屬性

回答

9

object['name']object.name完全一樣。只需分配一個關聯屬性並將其用作屬性即可。

5

取而代之點符號的,

tinymce_toolbar.t 

使用subscript notation

tinymce_toolbar[t]