Created
August 24, 2018 18:59
-
-
Save tallesairan/13820779ec44f0be7ce48face8005348 to your computer and use it in GitHub Desktop.
custom jquery event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.startDate = false; | |
window.endDate = false; | |
let dateOutSel = 'input[name="dateOut"]'; | |
let dateInSel = 'input[name="dateIn"]'; | |
$('label[for=dateOut]').hide('fast'); | |
$(dateOutSel).hide('fast'); | |
$(dateInSel).datepicker().on('changeDate', function(e) { | |
window.startDate = moment(e.date); | |
$('label[for=dateOut]').show('fast'); | |
$('input[name="dateOut"]').show('fast'); | |
}); | |
$(dateOutSel).datepicker().on('changeDate', function(e) { | |
window.endDate = moment(e.date); | |
$( document ).trigger( "getRoom", [ window.startDate, window.endDate ] ); | |
}); | |
$( document ).trigger( "getRoom", [ window.startDate, window.endDate ] ); | |
$( document ).on( "getRoom", { | |
meta: window | |
}, function( event, startDate, endDate ) { | |
console.log( event.data.meta ); // "window vars" | |
console.log( startDate ); // "bim" | |
console.log( endDate ); // "baz" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment