无法获得基本的SimpleModal& ASP.NET MVC 2工作:(帮助

时间:2010-11-25 20:30:39

标签: jquery asp.net-mvc asp.net-mvc-2 jquery-plugins simplemodal

我想做的就是获得使用ASP.NET MVC 2的SimpleModal的基本演示,我得到奇怪的行为......

我在做什么基本上是将index.html从demo转移到我的/Home的index.aspx主体。所以它看起来像这样:

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id='container'>
 <div id='logo'>
  <h1>Simple<span>Modal</span></h1>
  <span class='title'>A Modal Dialog Framework Plugin for jQuery</span>
 </div>
 <div id='content'>
  <div id='basic-modal'>
   <h3>Basic Modal Dialog</h3>
   <p>A basic modal dialog with minimal styling and no additional options. There are a few CSS properties set internally by SimpleModal, however, SimpleModal relies mostly on style options and/or external CSS for the look and feel.</p>
   <input type='button' name='basic' value='Demo' class='basic'/> or <a href='#' class='basic'>Demo</a>
  </div>

  <!-- modal content -->
  <div id="basic-modal-content">
   <h3>Basic Modal Dialog</h3>
   <p>For this demo, SimpleModal is using this "hidden" data for its content. You can also populate the modal dialog with an AJAX response, standard HTML or DOM element(s).</p>
   <p>Examples:</p>
   <p><code>$('#basicModalContent').modal(); // jQuery object - this demo</code></p>
   <p><code>$.modal(document.getElementById('basicModalContent')); // DOM</code></p>
   <p><code>$.modal('&lt;p&gt;&lt;b&gt;HTML&lt;/b&gt; elements&lt;/p&gt;'); // HTML</code></p>
   <p><code>$('&lt;div&gt;&lt;/div&gt;').load('page.html').modal(); // AJAX</code></p>

   <p><a href='http://www.ericmmartin.com/projects/simplemodal/'>More details...</a></p>
  </div>

  <!-- preload the images -->
  <div style='display:none'>
   <img src='img/basic/x.png' alt='' />
  </div>
 </div>
 <div id='footer'>
  &copy; 2010 Eric Martin | <a href='http://www.ericmmartin.com/'>ericmmartin.com</a> | <a href='http://twitter.com/ericmmartin'>@ericmmartin</a> | <a href='http://twitter.com/simplemodal'>@simplemodal</a>
 </div>
</div>

</asp:Content>

在我的Site.Master中,我包含演示中的所有js文件:

<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />


<!-- Load jQuery, SimpleModal and Basic JS files -->
<script type='text/javascript' src='/Scripts/jquery.js'></script>
<script type='text/javascript' src='/Scripts/jquery.simplemodal.js'></script>
<script type='text/javascript' src='/Scripts/basic.js'></script>

我认为它发现所有这些都很好......但是它不起作用。一旦它运行就会出现源:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

    Home Page

</title><link href="Content/Site.css" rel="stylesheet" type="text/css" />


    <!-- Load jQuery, SimpleModal and Basic JS files -->
    <script type='text/javascript' src='/Scripts/jquery.js'></script>
    <script type='text/javascript' src='/Scripts/jquery.simplemodal.js'></script>
    <script type='text/javascript' src='/Scripts/basic.js'></script>
</head>

<body>
    <div class="page">

        <div id="header">
            <div id="title">
                <h1>My MVC Application</h1>
            </div>

            <div id="logindisplay">

        [ <a href="/Account/LogOn">Log On</a> ]

            </div> 

            <div id="menucontainer">

                <ul id="menu">              
                    <li><a href="/">Home</a></li>
                    <li><a href="/Home/About">About</a></li>
                </ul>

            </div>
        </div>

        <div id="main">

    <div id='container'>
 <div id='logo'>
  <h1>Simple<span>Modal</span></h1>
  <span class='title'>A Modal Dialog Framework Plugin for jQuery</span>
 </div>
 <div id='content'>
  <div id='basic-modal'>
   <h3>Basic Modal Dialog</h3>
   <p>A basic modal dialog with minimal styling and no additional options. There are a few CSS properties set internally by SimpleModal, however, SimpleModal relies mostly on style options and/or external CSS for the look and feel.</p>
   <input type='button' name='basic' value='Demo' class='basic'/> or <a href='#' class='basic'>Demo</a>
  </div>

  <!-- modal content -->
  <div id="basic-modal-content">
   <h3>Basic Modal Dialog</h3>
   <p>For this demo, SimpleModal is using this "hidden" data for its content. You can also populate the modal dialog with an AJAX response, standard HTML or DOM element(s).</p>
   <p>Examples:</p>
   <p><code>$('#basicModalContent').modal(); // jQuery object - this demo</code></p>
   <p><code>$.modal(document.getElementById('basicModalContent')); // DOM</code></p>
   <p><code>$.modal('&lt;p&gt;&lt;b&gt;HTML&lt;/b&gt; elements&lt;/p&gt;'); // HTML</code></p>
   <p><code>$('&lt;div&gt;&lt;/div&gt;').load('page.html').modal(); // AJAX</code></p>

   <p><a href='http://www.ericmmartin.com/projects/simplemodal/'>More details...</a></p>
  </div>

  <!-- preload the images -->
  <div style='display:none'>
   <img src='img/basic/x.png' alt='' />
  </div>
 </div>
 <div id='footer'>
  &copy; 2010 Eric Martin | <a href='http://www.ericmmartin.com/'>ericmmartin.com</a> | <a href='http://twitter.com/ericmmartin'>@ericmmartin</a> | <a href='http://twitter.com/simplemodal'>@simplemodal</a>
 </div>
</div>



            <div id="footer">
            </div>
        </div>
    </div>
</body>
</html>

有什么看起来很奇怪吗?我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

在我看来,你错过了一个<script>块来实际使用/实现模态插件。

也许是这样的?

<script>
   $().ready({
       $('#basicModalContent').modal();
   });
</script>