Let's say I have couple of web pages where a single datepicker is used. In addition, I have another web page where I need 3 datepickers on the same page.
So how do I manage the java script id reference? Should I have single script in _layout.xml with something like this?
<script>
$(document).ready(function () {
$("#datepicker1").datepicker();
$("#datepicker2").datepicker();
$("#datepicker3").datepicker();
});
</script>
And all pages (besides the multiple) will have :
<div id="datepicker1"></div>
and the multiple will have:
<div id="datepicker1"></div>
<div id="datepicker2"></div>
<div id="datepicker3"></div>
I come from OO programming and something doesn't fit here. What are the conventions in web\js world to this common use case?
Edit: the mmultiple datepicker page script has different settings...
$('[id^="datepicker"]').datepicker(), but as has been noted below, the best solution is a common class.