I have a question about best practices when using jQuery / JavaScript / Ajax. Suppose I have some tasks, and there is a calendar for each task. The user can click on a day in the task calendar and book a task on a specific day through AJAX. I have to store the date and task id somewhere, and I use really weird identifiers for such as:
<span class="day_field" id="date_13-02-2013_task_4">13.02.2013</span>
Then I just attach the listener as follows:
$('.day_field').on('click',function(){ var date = $(this).id.split('_')[1]; var task_id = $(this).id.split('_')[3];
My question is: Is this right, how to do it? I'm not sure, because identifiers can be really long + it contains an identifier in the database, which is probably not stored at all.
Thanks! T.
source share