对话框功能错误无效功能

时间:2012-07-29 23:54:37

标签: javascript jquery html ajax load

TypeError:$(“”)。html(“此对话框每次都显示!”)。对话框不是函数

这是我得到的错误。使用索引页面上的div中的load()加载页面。我已经在索引页面(我希望保持这种方式),加载的页面和两者中包含必要的jquery内容,它仍然会这样做。我不确定到底是什么。我知道使用load()页面而不仅仅是页面本身更困难,但即使转到页面home.php,它仍然会说。下面是加载页面的链接,如果你想看到索引只是取出地址中的home.php。

The page that is being loaded

这是我正在使用的功能:

<script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.ui.core.js"></script>
    <script type="text/javascript" src="js/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="js/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="js/jquery.ui.position.js"></script>
    <script type="text/javascript" src="js/jquery.ui.resizable.js"></script>
    <script type="text/javascript" src="js/jquery.ui.widget.js"></script>

    <script type="text/javascript">
    function readMore(id,title,cat,desc,post,auth) {
        //alert(id +","+ title +","+ cat +","+ desc +","+ post +","+ auth);
        var $dialog = $('<div></div>').html('This dialog will show every time!').dialog({autoOpen: false,title: 'Basic Dialog'});
        $dialog.dialog('open');
        $dialog.title = title;
        $dialog.html(desc);
    }
    </script>

就像现在一样,对话框的所有包含都在加载页面上,而不是索引页面,但就像我说的那样,我尝试了其中一个或两个,但无济于事。警报工作正常,并正确传递一切,并在我想要它时被调用。 jquery包含的所有路径都是正确的。

如果由于某种原因它有助于缩小范围,我也会在页面加载时遇到错误: TypeError:$ .widget不是函数 [打破此错误]

_uiHash: function(event) {

jquery ... able.js(第504行)

TypeError:$ .widget不是函数 [打破此错误]

_mouseCapture: function(event) { return true; }

jquery ... ouse.js(第162行)

TypeError:$ .widget不是函数 [打破此错误]

ui: function() {

2 个答案:

答案 0 :(得分:3)

您还需要:

  • jquery.ui.button.js
  • jquery.ui.dialog.js

如上文Musa所述,将鼠标放在可拖动之前,这很重要。

摘要:

  1. jquery.ui.core.js
  2. jquery.ui.widget.js
  3. jquery.ui.mouse.js
  4. jquery.ui.position.js
  5. jquery.ui.draggable.js
  6. jquery.ui.resizable.js
  7. jquery.ui.button.js
  8. jquery.ui.dialog.js
  9. 但我没有加载所有单个文件,而是建议从CDN加载完整的UI。

     <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    

答案 1 :(得分:2)

jquery.ui.mousejquery.ui.draggablejquery.ui.resizable需要在jquery.ui.widget之后,因为他们会调用.widget(),小部件也会使用位置,因此请将其放在首位。

<script type="text/javascript" src="js/jquery.ui.position.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="js/jquery.ui.mouse.js"></script>
<script type="text/javascript" src="js/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="js/jquery.ui.resizable.js"></script>