【问题标题】:Modal window wont display from Javascript callJavascript调用不会显示模态窗口
【发布时间】:2015-04-30 12:33:16
【问题描述】:

我试图从 fullcalender.js 插件中弹出一个表单。我在引导模式 div 中有表单,并试图将其弹出、填写并将详细信息提交到数据库等。

问题是模态不会显示,我已通读 SO links such as this one 并改编了代码 @ 987654322@ 我已经复制/粘贴了在那里工作但不适合我的小提琴,是否存在问题,因为我的页面是 .jsp 页面还是我缺少 .js 文件。

我已经包含了所有的 bootstrap 和 fullcallender .js 文件,有什么建议吗?

  $('#myModal').modal('show');

这应该可以正常工作吗?但它似乎没有

编辑

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>       
    <script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>');</script>

    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/moment.min.js"></script>       
    <script src="js/fullcalendar.min.js"></script>

    <script type="text/javascript">

        $(document).ready(function () {

            var calendar = $('#calendar').fullCalendar({
                header: {
                   ...etc
                },                  
                defaultView: 'agendaWeek',
                editable: true,
                selectable: true,
                selectHelper: true,
                height: 846,
                select: function (start, end, allDay) {
                    endtime = $.fullCalendar.formatDate(end, 'h:mm tt');
                    starttime = $.fullCalendar.formatDate(start, 'ddd, MMM d, h:mm tt');
                    var mywhen = starttime + ' - ' + endtime;
                    $('#createEventModal #apptStartTime').val(start);
                    $('#createEventModal #apptEndTime').val(end);
                    $('#createEventModal #apptAllDay').val(allDay);
                    $('#createEventModal #when').text(mywhen);
                    $('#createEventModal').modal('show');
                }
            });

编辑

我的错误是 Uncaught TypeError: undefined is not a function

在这条线上

 endtime = $.fullCalendar.formatDate(end, 'h:mm tt');

【问题讨论】:

  • 我们将需要比这更多的代码来判断您是否遗漏了某些东西......并且错误消息也会有所帮助。
  • jsp???.. 这不是javascript
  • IDE 没有错误消息,它无论如何都没有抱怨,是的 @BrettCaswell jsp 不是 javascript,但是从 jsp 页面运行的一点 javascript 是什么?
  • @Aaron JSP 是一个 javaserver 页面,运行在服务器上,以 html+javascript 的形式返回响应。
  • @RomanC 是的,我正在尝试使用 javascript 在本地弹出一个表单,并在其中填写将在服务器端使用 java 处理的详细信息,因此是 Javaserver 页面,但这不是我的问题

标签: javascript jquery twitter-bootstrap fullcalendar typeerror


【解决方案1】:

已解决:)

我已经在新版本的 fullcalender.js 中更新了方法。我正在使用这个,

 endtime = $.fullCalendar.formatDate(end, 'h:mm tt');
 starttime = $.fullCalendar.formatDate(start, 'ddd, MMM d, h:mm tt');

当我应该使用这个时,

 starttime = moment(start).format('ddd, MMM do, h:mma ');
 endtime = moment(end).format('ddd, MMM do, h:mma ');

感谢您的帮助,希望这对其他人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-22
    • 2018-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多