Apply jQuery datepicker to multiple instances

后端 未结 12 2356
时光说笑
时光说笑 2020-11-27 14:04

I\'ve got a jQuery date picker control that works fine for once instance, but I\'m not sure how to get it to work for multiple instances.



        
12条回答
  •  野性不改
    2020-11-27 14:42

    A little note to the SeanJA answer.

    Interestingly, if you use KnockoutJS and jQuery together the following inputs with different IDs, but with the same data-bind observable:

    
    
    

    will bind one (the same) datepicker to both of the inputs (even though they have different ids or names).

    Use separate observables in your ViewModel to bind a separate datepicker to each input:

    
    
    

    Initialization:

    $('.datepick').each(function(){
        $(this).datepicker();
    });
    

提交回复
热议问题