简体   繁体   中英

Hook Bootstrap Daterangepicker

i am using this template http://www.keenthemes.com/preview/metronic/index.html

which provides a nice timepicker in the right corner.

However i am unable to submit anything if the user presses the submit button.

This is the library which they use and the exact example http://www.dangrossman.info/2012/08/20/a-date-range-picker-for-twitter-bootstrap/

how can i submit the picked range if the user clicks on the submit button or any given link like "last 7 days"?

any formsubmit, listener or clickfunction would be fine ... but i dont get it working.

Because the control has two textboxes, it will update those. However if you want to use that in your application, you can have a textbox (or textboxes) that will be updated by the "onApply" method of the control. In our case we used a 1 textbox and update it with the range.

$('#filterDates').on('apply.daterangepicker', function (ev, picker) {
    try {
        $('#txtStartDate').val(picker.startDate.format('DD MMM YYYY'));
        $('#txtEndDate').val(picker.endDate.format('DD MMM YYYY'));
        //this is what we actually use
        $('#txtFilterDates').val(picker.startDate.format('DD MMM YYYY') + ' - ' + picker.endDate.format('DD MMM YYYY'));
    } catch (ex) {
        console.error(ex);
    }
});

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