2016-08-22 16 views
1

私のサイトに実装したい素晴らしいコメントプラグインがあります。ここにはhttps://github.com/Viima/jquery-commentsがあります。jQuery-commentsプラグインが実行されていません

しかし、プラグインを使用して実装しようとすると何かが表示されるのが困難です。どんな提案も素晴らしいだろう。以下は私のコードです。 (しかし私は、外部リソースは、「HTTPS ..」で始まるリンクを必要JSFiddleを提供するだろうと私は、「HTTP ...」で始まる)

HTML

<!doctype html> 
<html> 
    <head> 
     <meta name=description content=""> 
     <meta name=viewport content="width=device-width, initial-scale=1"> 

     <link rel="stylesheet" type="text/css" href="http://**MYURL**.net/jquery-comments.css"> 
     <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> 

     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> 
     <script type="text/javascript" src="http://**MYURL**.net/jquery-comments.js"></script> 
    </head> 

    <body> 
     <div id="comments-container"></div> 
     <script type="text/javascript"> 
     $('#comments-container').comments({ 
     getComments: function(success, error) { 
      var commentsArray = [{ 
       id: 1, 
       created: '2015-10-01', 
       content: 'Lorem ipsum dolort sit amet', 
       fullname: 'Simon Powell', 
       upvote_count: 2, 
       user_has_upvoted: false 
      }]; 
      success(commentsArray); 
     } 
     }); 
     </script> 
    </body> 
</html> 

答えて

1

次のコードの一部があなたをタイプされているいくつかの問題があります。

<script rel="text/javascript" href="http://**MYURL**.net/jquery-comments.js"></script> 

あなたは最終的には、次のいずれかでのコードの前述のブロックを交換する必要があります代わりにtype="text/javascript"src="http://**MYURL**.net/jquery-comments.js"

rel="text/javascript"href="http://**MYURL**.net/jquery-comments.js"を使用している:

<script type="text/javascript" src="http://**MYURL**.net/jquery-comments.js"></script> 

スクリプトタグを使用していますタイプコールするドキュメントのタイプを示す属性エド(これは、最新のJavascript標準に従ってもはや使用するのは実際には良い習慣ではありません)。また、スクリプトタグ内でJavascriptファイルを読み込むには、hrefの代わりにsrc属性を使用する必要があります。

コードを次のコードと比較してください。https://github.com/Viima/jquery-comments#quick-start

+0

それを修正しました。ありがとうございました。また、新しいjavascript標準で 'type'以外の他の属性を使用する方が適切ですか? – RyeGuy

+0

私はあなたの問題を修正してうれしいです。 HTML5は、特定のソースを指しているときに読み込まれるスクリプトの種類を理解するのに十分なほど賢明です。したがって、単に 'type =" text/javascript "'を省略しても問題ありません。 –

+0

よかった。再度、感謝します – RyeGuy

関連する問題