edekmax
edekmax

Reputation: 89

How to run this only once after page load?

$(document).ready(function(){
    $('#b').datepicker().on('changeDate', recalculate_deadline);
    $('#id_field').change(recalculate_deadline);
    $('#id_field_type').change(recalculate_deadline);

    $('#id_other_field').change(check_reminder_date);
    $('#id_time').datepicker().on('hide', check_reminder_date); #this

});

How to run this only once after page load?

$('#id_time').datepicker().on('hide', check_reminder_date);

For now If I change date, this function - "check_reminder_date" is running. I want to run this only once after page load, after user can change date manualy(without check_reminder_date function)

Upvotes: 0

Views: 790

Answers (1)

Christophe
Christophe

Reputation: 28124

To run a handler only once, you can use one() instead of on():

$('#id_time').datepicker().one('hide', check_reminder_date);

See this page for more info.

Upvotes: 2

Related Questions