How to appoint a $j.current.m object ?

1 view
Skip to first unread message

Alex

unread,
Mar 18, 2009, 4:29:50 PM3/18/09
to Jamal MVC
Hi Timo,

How to appoint a $j.current.m object ?

I read the source code of jamal, i don't get it .

Thank you.


Alex

浩翔

unread,
Mar 18, 2009, 4:42:48 PM3/18/09
to Jamal MVC
I know.
$j.current.m is the singular form of the controller name.

Timo Derstappen

unread,
Mar 19, 2009, 5:24:08 AM3/19/09
to jama...@googlegroups.com
Hey Alex!

2009/3/18 浩翔 <blacka...@gmail.com>:


>
> I know.
> $j.current.m is the singular form of the controller name.

Problem solved?

If you have a users_controller.js in app/controllers and configure
jamal with eg {controller:users,action:index} you can use $j.current.m
in the controller without doing anything. The model is created on the
fly. But if you like to add a method to the user model you have to
create app/models/user.js:

$j.m({User:{
yourMethod: function(){}
}});


Cheers,
Timo

--
Timo Derstappen

http://teemow.com
mailto:tee...@gmail.com

Alex

unread,
Mar 19, 2009, 9:51:39 AM3/19/09
to jama...@googlegroups.com
Hi Timo,

I see, thank you very much!
however, I create my app/models/user.js
I can't use $j.current.m.mymethod, I just use $j.m.User.mymethod.

i add the method like this, i can use $j.current.m.mymethod.

$j.extend($j.fn.m.prototype, {
.mymethod: function(){}
});

Timo Derstappen

unread,
Mar 19, 2009, 10:01:07 AM3/19/09
to jama...@googlegroups.com
Hey Alex,

could you put your code in some pastebin? I really don't get, what you
are doing :)

Greez,
Timo

Alex

unread,
Mar 19, 2009, 10:15:17 AM3/19/09
to jama...@googlegroups.com
I'm sorry.


I want to add mymethod to model and want to use it like this:

$j.current.m.mymethod

now i add mymethod to app_model.js

$j.extend($j.fn.m.prototype, {

mymethod: function(){};
});

so i can use it with $j.current.m.mythod() , my problem have
solved. thank you!
Reply all
Reply to author
Forward
0 new messages