2012-03-04 16 views
0

私はモーダルを更新し、フォームをレンダリングするカラーボックスの中にボタンを実装しようとしています。Colorboxでボタンをクリックした後にフォームをレンダリングするにはどうすればよいですか?

この例は、Pinterestの追加機能です。 "Homepage > Add a Pin > Pin URL"

ColorboxのインラインHTMLの例をコピーしようとしました。

<script type="text/javascript"> 
$(document).ready(function() { 
    $(".inline").colorbox({inline:true, width:"50%"}); 

    $('a[rel="colorbox"]').live("click", function() { 

    $.colorbox({ 
     open: true, 
     href: this.href 
    }); 

    return false; 
    }); 
}); 
</script> 

     <div style='display:none'> 
      <div id='inline_content' style='padding:10px; background:#fff;'> 
      <p><strong>Add a Promotion</strong></p> 
      <p><a id="click" href="#" style='padding:5px; background:#ccc;'>Click me, it will be preserved!</a></p> 
      <p><strong>If you try to open a new ColorBox while it is already open, it will update itself with the new content.</strong></p> 
      <p>Updating Content Example:<br /> 
      <a class="ajax" href="**shared/promotion_form**" rel="colorbox">Add a Promotion</a></p> 
      </div> 
     </div> 

問題は、フォームが_promotion_form.html.erbであるため、リンクできません。

答えて

0

レベルをあなたのセレクタを移動してみてください、そしてたぶんjQueryの1.7.1 にこのような何か更新:

$('body').on("click", "a[rel="colorbox"]", function() {

あなたはそのセレクタを持つすべての要素のために身体を監視していますので、この方法を"a [rel = 'colorbox']"

これが役に立ちます。

+0

セレクタが今動作しています。私が問題を抱えているのは、href経由でリンクするのではなく、プロモーションフォームをレンダリングする方法がわからないということです。 – toandang

+0

ああ.... hrefプロパティの代わりにhtmlプロパティを使用するだけで、値は文字列またはjQueryオブジェクトになります。 – Relic

関連する問題