How to bind jQuery Datepicker after Ajax refresh?

前端 未结 4 696
误落风尘
误落风尘 2021-01-14 04:44

I\'ve got a jQuery datepicker that is working great for me, except when I fresh the content via ajax, I lose the datepicker. From what I can tell I should be using jQuery on

4条回答
  •  死守一世寂寞
    2021-01-14 05:32

    You can not delegate plugin, delegation is for event listener only. Use the success callback function and reinitailize datepicker plugin once targeted element is added

    success: function (data, textStatus) {
        $("#content").html(data).find('[id^=startPicker]').datepicker({...});
    },
    

提交回复
热议问题