简体   繁体   English

jQuery模式第二次不工作

[英]Jquery modal not working second time

I am developing one application using codeigniter. 我正在使用codeigniter开发一个应用程序。 In this application got a problem that modal window is not opening second time. 在此应用程序中出现了一个问题,即模态窗口没有第二次打开。

In detail . 详细 。

I have form(view) which contains two select box and search button. 我有form(view),其中包含两个选择框和搜索按钮。 User will select the options then click on search button it will display a paginated result . 用户将选择选项,然后单击搜索按钮,将显示分页结果。 I am using ajax to get the result. 我正在使用ajax获得结果。 The pagination is also based on ajax. 分页也基于ajax。 On this table result user can edit or update any of the records. 用户可以在此表结果上编辑或更新任何记录。 Here comes the issue. 问题来了。 I am displaying the update form inside a modal window. 我在模态窗口中显示更新表单。 Inside that modal window I have to do some jquery validations. 在该模式窗口内,我必须执行一些jquery验证。 For that I am including jquery library. 为此,我包括jQuery库。 The moment when I hit on the edit button for the first time, the modal window is showing and second time it is throwing an error 当我第一次点击编辑按钮时,模态窗口正在显示,而第二次则抛出错误

Uncaught TypeError: Object [object Object] has no method 'modal' 

If I removed the jquery library from the modal window then it is working fine. 如果我从模式窗口中删除了jQuery库,那么它运行良好。

The code which I am using on this is 我在此使用的代码是

My first view 我的初见

 <script src="<?php print base_url()?>js/dboard.js" type="text/javascript"></script>       
 <script type="text/javascript" src="<?php print base_url()?>js/jquery.min.js"></script>
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

 <script type="text/javascript">
    $(document).ready(function(){               
       $('#view_all').bind("click",function(e){
            var pubid = $('#pub').val();            
            var magid = $('#mag').val();
            var limit = 0; 
            $.post('../user/ajax_view_all',{p_id:pubid,m_id:magid,l:limit},function (data){     
        $('#result_table').html(data);
            });
            //Load pagination on ajax click
            $(document).on("click",".pagination a",function(event){
              var url = $(this).attr("href"); 
              var limit = url.substring(url.lastIndexOf('/') + 1);
              jQuery('.pagination a').removeClass('active');                    
                    $.post($(this).attr('href'),{p_id:pubid,m_id:magid,l:limit},function (data){                                            
                $('#result_table').html(data);
            });                         
             return false; 
            });

                //Open update form in modal window
            $(document).on("click",".btn-setting",function(e){
             edit_id = 2;
             $("div[id='myModal']").modal();
             $.post('../user/update_publishing_modal',{ed_id:edit_id},function(data){
              $('.modal-body').html(data);
            });
            e.preventDefault();
            return false;
            });             

        });
      });        
    </script>

Modal form in the same page. 模态形式在同一页上。

<div class="modal hide fade" id="myModal">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3>Update Schedule</h3>
  </div>
  <div class="modal-body"></div>
  <div class="modal-footer">
    <a href="#" class="btn" data-dismiss="modal">Close</a>
    <a href="#" class="btn btn-primary">Save changes</a>
 </div>
</div>

please tell what is the issue with this. 请告诉我这是什么问题。 How can I include the jquery library inside the modal window. 我如何在模态窗口内包含jquery库。

I see a minor issue with misplaced braces, not sure if it can cause this issue: you need to replace : 我看到一个大括号放置不当的问题,不确定是否会导致此问题:您需要更换:

        });             
        }
    });
  });  

with : 与:

        });
    });
});

at the end of the script. 在脚本末尾。

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

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