Topic: UJS: how to apply more than one behaviour

Hi!

I'm not good javascipt person yet, so this question might look basic.

Ok, I'm using UJS plugin and would like to apply two behaviours to one object

I'll give you code what I have, but it does not work because two behaviours using one object #card_question

<%= apply_behaviours {
   on '#card_question', make_observed( :card_question,
                                      :on => "changed",
                                      :update => :live_search,
                                      :url => {:action => :live_search},
                                      :loading => "Element.show('search-indicator')",
                                      :complete => "Element.hide('search-indicator')" )
  on '#card_question', '$(this).focus()'} %>

And it produces javascript:
Event.addBehavior({
"#card_question": function(event) {
new Form.Element.EventObserver(this, function(element, value) {new Ajax.Updater('live_search', '/cards/live_search', {asynchronous:true, evalScripts:true, onComplete:function(request){Element.hide('searching');Element.hide('search-indicator')}, onLoading:function(request){Element.show('searching');Element.show('search-indicator')}, parameters:value})}, 'changed');
},
"#card_question": function(event) {
$(this).focus();
}
});

By the way, when I take away the second behaviour and use like bellow then things working.
<%= apply_behaviours {
   on '#card_question', make_observed( :card_question,
                                      :on => "changed",
                                      :update => :live_search,
                                      :url => {:action => :live_search},
                                      :loading => "Element.show('search-indicator')",
                                      :complete => "Element.hide('search-indicator')" )
<script type="text/javascript">
  $("card_question").focus();
</script>

However, I would like to make it happend using UJS, so do you have any hints how to do it using UJS only?

Thanks,
Priit

Estonian ruby coders => http://ruby.ee