简体   繁体   中英

How can we initialise datepicker into a textbox which is appended by ajax

In yii framework of PHP I'm trying to append a textbox then initialise the datepicker. I already have two static textbox with datepicker working fine in the from and two more needed to be added and datepicker be initialised in those textbox.

When I'm trying to initalise after ajax success call. It is showing

datepicker is not a function

My ajax call :

$.ajax({
            type: 'get',
            url: url,
            cache: false,
            dataType: 'html',
            success: function (html) {
                $('.append_more_parents:last').append(html);
                var num_form = parseInt($('.count').length + 2);
                $('.count:last').text('Parental Responsibility ' + num_form);
                $form = $('#appended_form');
                $form.replaceWith($form.html());
                container_id++;
                $('#datepicker').datepicker();
            },
            error: function (err) {
                bootbox.alert('Sorry adding of parental details failed! Please try again');
            }
});

如果显示“ datepicker不是函数”,似乎HTML页面中不包含Jquery datepicker库?

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