Can I use two action in the same page ?

1 view
Skip to first unread message

浩翔

unread,
Mar 17, 2009, 4:25:15 AM3/17/09
to Jamal MVC
Hi guys,

I want to use two action in a same page ,like this :


$c.Clients = {
index: function() {


$v.Clients.showList($m.Client.select());

$('#save').bind('click',function(){

$m.Client.insert([$('#firstname').val(),$('#lastname').val()]);
$v.Clients.showList($m.Client.select());
});
},

new: function() {
$('#new').bind('click', function(){
alert('new action');
});
}
};


In my index.html, i use it like this:
<body class="jamal
{controller:'Clients',action:'index',debug:true},
{controller:'Clients',action:'new',debug:true}, ">


however, it didn't work . are there anyway to implement ?

thank you!

Alex


Alex

unread,
Mar 17, 2009, 5:00:42 AM3/17/09
to jama...@googlegroups.com
Hi Timo,

Could you give me a reply ?
Thank you.

Alex

Timo Derstappen

unread,
Mar 17, 2009, 5:03:50 AM3/17/09
to jama...@googlegroups.com
Hey Alex,

first it is better to use:

$j.c({Clients: {
index: function () {}
}});

This way the controller inherits all methods from the app controller.
You can access the controller via $j.c.Clients or $j.current if it is
the controller on the current page.

To call another controller method you can do this:

$j.c({Clients: {
index: function () {
this.new();
// or
$('.new').click(function(){
$j.current.new();
});
},

new: function() {}
}});


Hope that helps,
Timo

2009/3/17 浩翔 <blacka...@gmail.com>:
--
Timo Derstappen

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

Alex

unread,
Mar 17, 2009, 5:17:02 AM3/17/09
to jama...@googlegroups.com
Hi Timo,

I see. Thank you very much. :)


Alex
Reply all
Reply to author
Forward
0 new messages