Binding multiple chains

So far you've seen how we can make chains, and then bind them to one - or multiple - triggers. What about binding multiple chains to a single trigger? That's where the second argument to js() function is used.

The call syntax is js(trigger, prepend_js). As a second argument, you can pass either a JS chain, or an array of JS chains.

Result

Bounce

Highlight

 

Code

$js=array();

$js[]=$page->add('P')->set('Bounce')
    ->
js()->effect('bounce');

$js[]=$page->add('P')->set('Highlight')
    ->
js()->effect('highlight');

$page->add('Button')->set('Trigger Both')
    ->
js('click',$js);

Alternatively you can also bind the same action several times. This syntax can be used when actions are applied by controllers, or from multiple objects.

Result

Bounce

Highlight

 

Code

$js1=$page->add('P')->set('Bounce')
    ->
js()->effect('bounce');

$js2=$page->add('P')->set('Highlight')
    ->
js()->effect('highlight');

$b=$page->add('Button')->set('Trigger Both');

$b->js('click',$js1);
$b->js('click',$js2);