Skip to content

autoclose() should trigger datepicker-apply #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -856,7 +856,9 @@ <h2>Events</h2>
})
.bind('datepicker-apply',function(event,obj)
{
/* This event will be triggered when user clicks on the apply button */
/* This event will be triggered when user clicks on the apply button.
If opt.autoClose is true or opt.showTopbar is false this will also
be triggered when the final date is clicked */
console.log(obj);
})
.bind('datepicker-close',function()
30 changes: 23 additions & 7 deletions src/jquery.daterangepicker.js
Original file line number Diff line number Diff line change
@@ -920,13 +920,7 @@
box.find('.apply-btn').click(function()
{
closeDatePicker();
var dateRange = getDateString(new Date(opt.start))+ opt.separator +getDateString(new Date(opt.end));
$(self).trigger('datepicker-apply',
{
'value': dateRange,
'date1' : new Date(opt.start),
'date2' : new Date(opt.end)
});
triggerApply();
});

box.find('[custom]').click(function()
@@ -1357,6 +1351,7 @@
showSelectedInfo();
showSelectedDays();
autoclose();
if (opt.start && opt.end) triggerApply();
}


@@ -1386,6 +1381,7 @@
showSelectedInfo();
showSelectedDays();
autoclose();
triggerApply();
}

function isValidTime(time)
@@ -1559,6 +1555,26 @@
}
}
}

function triggerApply()
{
if (opt.singleDate === true) {
var dateRange = getDateString(new Date(opt.start));
$(self).trigger('datepicker-apply',
{
'value': dateRange,
'date1' : new Date(opt.start)
});
} else {
var dateRange = getDateString(new Date(opt.start))+ opt.separator +getDateString(new Date(opt.end));
$(self).trigger('datepicker-apply',
{
'value': dateRange,
'date1' : new Date(opt.start),
'date2' : new Date(opt.end)
});
}
}

function checkSelectionValid()
{