简体   繁体   中英

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM