Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get dynamic properties in javascript [duplicate]

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);

how i do it to be dynamic? Thanks

like image 221
ZiTAL Avatar asked Sep 22 '10 08:09

ZiTAL


1 Answers

object['name'] is quite same way as object.name. simply assign a associative attribute and use it as a property.

like image 54
Tomasz Kowalczyk Avatar answered Sep 17 '22 20:09

Tomasz Kowalczyk