2012-02-17 17 views
0

Ivはちょっとこれに固執していますので、私は誰か他の人にもっとスマートに尋ねるでしょう:)私はprettyPhoto Jqueryプラグインを使用しようとしている.NET Webサイトを持っています。私はマスターページにJqueryメインライブラリとPrettyPhoto.jsファイルを含めました。私は他のJqueryプラグインでも同様の問題を抱えていますが、ライブラリ内の関数を見つけることができない場合、これらの問題を回避するにはどうすればよいでしょうか?私はマスターページのすべてのJqueryファイルを正しく保持するはずですか?と同様にCSSのリンク?私は自分のページにコードを投稿しました。prettyPhoto()関数を取得する方法をコードで例を挙げてください。前もって感謝します!!ASP.net JqueryはprettyPhoto()関数を見つけることができません

<%@ Page Title="" Language="C#" MasterPageFile="~/Project.Master"  
    AutoEventWireup="true" CodeBehind="Portfolio.aspx.cs" Inherits="Project.Portfolio" %> 
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 

<script type="text/javascript" charset="utf-8"> 
    $(document).ready(function() { 
    debugger; 
     //This throws error Object doesn't support property or method 'prettyPhoto' 
     $("ul.gallery").prettyPhoto(); 
    }); 
</script> 
    <link rel="stylesheet" href="../Stylesheets/prettyPhoto.css" type="text/css"  
    media="screen" title="prettyPhoto main stylesheet" charset="utf-8" /> 
    <style type="text/css" media="screen"> 

    ul li { display: inline; } 

    </style> 

    </asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> 

<div id="main"> 
<h2>Gallery</h2> 
     <ul id="picGallery" class="gallery"> 
      <li><a href="../images/Portfolio/fullscreen/2krew.jpg"  
rel="prettyPhoto[gallery1]" title="You can add caption to pictures. You can add  
caption to pictures. You can add caption to pictures."><img src="../images/thumbnails 
/2Krewtn.jpg" width="200" height="200" alt="Red round shape" /></a></li> 
      <li><a href="../images/Portfolio/fullscreen/anaura" 
rel="prettyPhoto[gallery1]" title="You can add caption to pictures. You can add 
caption to pictures. You can add caption to pictures."><img src="../images/thumbnails 
/anauratn.jpg" width="200" height="200" alt="Red round shape" /></a></li> 
      <li><a href="../images/Portfolio/fullscreen/closed.jpg" 
rel="prettyPhoto[gallery1]" title="You can add caption to pictures. You can add 
caption to pictures. You can add caption to pictures."><img src="../images/thumbnails 
/Closedtn.jpg" width="200" height="200" alt="Red round shape" /></a></li> 

     </ul> 

</div> 

</asp:Content> 
+0

を追加しました私はあなたが正常に動作してから、スクリプトを妨げる可能性のある例外を取得するかどうかを確認するために[Firebugの](http://getfirebug.com/)で開始したいです(そしてあなたのスクリプトファイルが実際にロードされている場合) –

答えて

0

私はこれが正しいアプローチであるかどうかわからないんだけど、jQueryのdocument.readyいうし、スタンダールjavascriptのコードでjQueryのプラグを発射jQueryとマスターページと、この問題を解決するために:

私のページの下部に

私はこのコード

<script type="text/javascript"> 
    StartJqeryPlugin(); 

    function StartJqeryPlugin() { 

     window.setTimeout(function() { 
     $("ul.gallery").prettyPhoto(); 
     }); 
     }, 250); 
    } 
関連する問題