简体   繁体   中英

Bootstrap-Datepicker icon click event not working

I have the following template containing a calendar icon in a javascript file. It doesn't appear in my html file because it's used dynamically.

var iconTemplate = '<li id=\"{streamID}\" class=\"list\">{streamName} <i class="fa fa-calendar pull-right"></i></li>';

I want to add a click event to the calendar icon and open date picker. I tried the following:

    $('.fa-calendar').click(function(){
      $(this).datepicker();
    });

I'm guessing that this doesn't work because it's not calling on a class from the html file. Is it possible to do this all within a javascript file?

$(document).on('click, '.fa-calendar', function(){
    ...

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