I have a PHP class with a static function:
<? echo view::getUserSelector() ?>
Which outputs:
<div id="user_selector">
<div class="user">
<h1>Username1</h1>
<a href="javascript:selectUser(this);">select</a>
</div>
<div class="user">
<h1>Username2</h1>
<a href="javascript:selectUser(this);">select</a>
</div>
</div>
What do I need to do to make this possible?:
<? echo view::getUserSelector(array('onSelect' => 'function() { alert(this.id); }')); ?>
- How do I 'add' the
onSelect
-value as a function ofdiv#user_selector
? - How do I 'call'
div#user_selector.onSelect()
withthis
reference asdiv#user_select
?
Javascript:
function selectUser(anchor) {
//remove all 'selected' classes from $user_selector child divs
//add 'selected' class to parent div.user of anchor
}