I have the cell contains a image and I want to do something when the img is clicked.
$buttons = <<<EOD
<img src="icon.png" rowid="$item->id" onclick="deleteRow('$template_name',$item->id)" class="deleteRow"/>
EOD;
$buttons = htmlspecialchars($buttons);
$row = <row><cell title="Delete Row">$buttons</cell></row>
The above code is working with the onclick event. However, if I take out the onclick and use jQuery event. The event does not fire when img is clicked.
$buttons = <<<EOD
<img src="icon.png" rowid="$item->id" class="deleteRow"/>
EOD;
In my view
<script>
$(document).ready(function() {
$('.deleteRow').live('click', function(){
//do something such as deleteRow('$template_name',$item->id)
});
};
</script>
I do not know what Dhtmlx Grid does to jQuery but the above codes does not fire. The only way onclick works is using ‘onclick’ inside img which is a bad javascript practice.
Thanks.
Michael