I just read in a best practices article for jquery and ajax that I should avoid defining behavior for elements on the page with inline script. That does make sense since it makes the code very readable.
However, I want to ask what should I do then, if I need to pass server-side variables to javascript. Like consider the following code...
<?php foreach($product as $product_id): ?>
<input type="button" value="Delete Favorite" onclick="delete_favorite('<?php echo $product_id; ?>')" />
<?php endforeach; ?>
Should I be using hidden form values for such a case? or may be adding adding the server side variable in the id of element I am defining the behavior for? like so..
<input type="button" value="Delete Favorite" id="button<?php echo $product_id; ?>" />
Any suggestions?