2011-09-19 11 views
0

コンテナボックスを表示するアイコンをクリックすると、コンテンツをプッシュするAjaxコンテンツボックスをセットアップしようとしています。コンテナの内容をコンテナ内にロードする

よく、問題は、コンテンツがコンテナの内部ではなく本体の外側にロードされていることです.jqueryドキュメントによれば、この関数を追加すると誰もがページを読み込まない理由がわかりますコンテナに?あなたはそれが#buser-boxの内側にロードしたい場合は、単に

$(function(){ 
    $('.user-link a') .click(function(e){ 
     var a = $(this), 
      href = a.attr('href'), 
      content = a.appendTo('#buser-box'); 

     content.load(href + '#buser-box'); 
     e.preventDefault(); 
     $('#buser-box').show('fast'); 
    }); 
}) 

感謝:)

+0

あなたは、ID = BUSERボックスを持つ要素を持っていますか? – bfavaretto

答えて

1

私は問題がcontent変数であると思います。

これを試してみてください:

$(function(){ 
    $('.user-link a') .click(function(e){ 
     var a = $(this), 
      href = a.attr('href'), 
      box = $('#buser-box'), 
      content = a.appendTo(box); // This may not be necessary 

     // Loading into the div, not the appended to element, might not be what you want. 
     box.load(href + '#buser-box'); 
     e.preventDefault(); 
     $('#buser-box').show('fast'); 
    }); 
}); 
+0

しかし、なぜこれをjqueryドキュメントに追加することをお勧めしますか?ちなみに – dcalixto

+0

、ありがとうございます:) – dcalixto

0

の操作を行います。

$('#buser-box').load(href + '#buser-box'); 
関連する問題