Trying to Execute a function by reference.

0 views
Skip to first unread message

jiggliemon

unread,
Feb 16, 2010, 7:57:23 PM2/16/10
to MooTools Users
Anyone have any insight as to how I could execute a function by
reference?

http://mootools.net/shell/yL93N/1/

-Chase

jiggliemon

unread,
Feb 16, 2010, 8:11:18 PM2/16/10
to MooTools Users

chone

unread,
Feb 16, 2010, 8:22:09 PM2/16/10
to mootool...@googlegroups.com
you can put these function in a object,like this

Ryan Florence

unread,
Feb 16, 2010, 8:29:24 PM2/16/10
to mootool...@googlegroups.com
I'd do it like this:

http://mootools.net/shell/yL93N/6/

jiggliemon

unread,
Feb 16, 2010, 8:54:08 PM2/16/10
to MooTools Users
My end goal is to load a class that will act as a template, So to add
new templates, all i need to do is add another js file with a template
class in it:

js file:
=========
templates.push({title:'generic'});
var generic = new Class({});


template chooser:
========
if(templates.length > 0) {
select = new Element('select');

templates.each(function(el){
opt = new Option(el.title,el.title);
select.grab(opt);
});
}


so something like this w/ eval.
http://mootools.net/shell/yL93N/7/

Arian

unread,
Feb 17, 2010, 5:34:21 AM2/17/10
to MooTools Users
eval is evil!

I would use the suggestions of chone or ryan.


On Feb 17, 2:54 am, jiggliemon <ch...@agroism.com> wrote:
> My end goal is to load a class that will act as a template, So to add
> new templates, all i need to do is add another js file with a template
> class in it:
>
> js file:
> =========
> templates.push({title:'generic'});
> var generic = new Class({});
>
> template chooser:
> ========
> if(templates.length > 0) {
>     select = new Element('select');
>
>     templates.each(function(el){
>         opt = new Option(el.title,el.title);
>         select.grab(opt);
>     });
>
> }
>

> so something like this w/ eval.http://mootools.net/shell/yL93N/7/

Thierry bela nanga

unread,
Feb 17, 2010, 5:57:17 AM2/17/10
to mootool...@googlegroups.com
Also eval could break your js if you minify your js with google compiler, you should avoid it,

--
http://tbela99.blogspot.com/

fax : (+33) 08 26 51 94 51
Reply all
Reply to author
Forward
0 new messages