kartik-v / yii2-date-range

A Date Range Picker for Bootstrap useful for reports and filtering.
http://demos.krajee.com/date-range
Other
93 stars 81 forks source link

Multiple usage in one page and "apply.daterangepicker" event #60

Closed izemize closed 8 years ago

izemize commented 8 years ago

Hi

I use this nice widget twice on my view, but only once render on(.apply.daterangepicker javascript code. Hm.. what's wrong?

<?=DateRangePicker::widget([
                'options'=>['id'=>'one'],
                'name'=>'studentrange',
                'convertFormat'=>true,
                'pluginOptions'=>[
                    'id'=>'one',
                    'locale'=>['format'=>'Y/m/d'],
                    'separator'=>'-',
                ],
                'pluginEvents'=>[
                    "apply.daterangepicker"=>"function(){ $('#filter').submit(); }",
                ]
            ]);?>
<?=DateRangePicker::widget([
                'options'=>['id'=>'two'],
                'name'=>'teacherrange',
                'convertFormat'=>true,
                'pluginOptions'=>[
                    'id'=>'two',
                    'locale'=>['format'=>'Y/m/d'],
                    'separator'=>'-',
                ],
                'pluginEvents'=>[
                    "apply.daterangepicker"=>"function(){ $('#filter').submit(); }",
                ]
            ]);?>
jQuery(document).ready(function () {
if (jQuery('#w1').data('daterangepicker')) { jQuery('#w1').daterangepicker('destroy'); }
jQuery("#w1").daterangepicker(daterangepicker_5675aeba, function(start,end,label){var val=start.format('YYYY/MM/DD') + ' - ' + end.format('YYYY/MM/DD');jQuery("#w1").val(val);jQuery("#w1").trigger('change');});
jQuery("#w1").on('apply.daterangepicker', function(){ $('#filter').submit(); });

if (jQuery('#w2').data('daterangepicker')) { jQuery('#w2').daterangepicker('destroy'); }
jQuery("#w2").daterangepicker(daterangepicker_5ca83dc4, function(start,end,label){var val=start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD');jQuery("#w2").val(val);jQuery("#w2").trigger('change');});

jQuery(document).pjax("#w0 a", "#w0", {"push":true,"replace":false,"timeout":1000,"scrollTo":false});
jQuery(document).on('submit', "#w0 form[data-pjax]", function (event) {jQuery.pjax.submit(event, '#w0', {"push":true,"replace":false,"timeout":1000,"scrollTo":false});});
$(function () {
    $("[data-toggle='tooltip']").tooltip();
});;
$(function () {
    $("[data-toggle='popover']").popover();
});
});
``
izemize commented 8 years ago

My fault