简体   繁体   English

Bootstrap-Datepicker图标点击事件无效

[英]Bootstrap-Datepicker icon click event not working

I have the following template containing a calendar icon in a javascript file. 我有一个包含javascript文件中的日历图标的以下模板。 It doesn't appear in my html file because it's used dynamically. 它没有出现在我的html文件中,因为它是动态使用的。

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. 我猜这不起作用,因为它没有调用html文件中的类。 Is it possible to do this all within a javascript file? 是否可以在javascript文件中完成所有操作?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM