2012-11-18 13 views
3

Embedly/jquery-Preview已經太棒了。但是,我試圖改變預覽結果的位置,並遇到麻煩。現在,結果出現在輸入字段下方......但我寧願將它放在頁面的單獨部分。有沒有辦法做到這一點?Embedly(JQuery-Preview)結果的位置

我試着改變選擇器的位置和加載div,但是這並沒有幫助。它似乎忽略這些div,並將其放在提交按鈕的正下方。

下面是我的代碼:

<form accept-charset="UTF-8" action="private" class="new_comment" data-remote="true" id="new_comment" method="post"> 
    <input class="photo_comm" id="comment_comment" name="comment[comment]" placeholder="add a comment or link..." size="30" type="text" /><span type="text" id="counter">1000</span> 
    <input class="btn btn-primary btn-mini" data-disable-with="Submitting..." name="commit" type="submit" value="Post" /> 
    </form> 

    <!-- Placeholder that tells Preview where to put the loading icon--> 
    <div class="loading"> 
     <img src='http://embedly.github.com/jquery-preview/images/loading-rectangle.gif'> 
    </div> 

    <!-- Placeholder that tells Preview where to put the selector--> 
    <div class="selector"></div> 

$('#comment_comment').preview({ key:'60f1dcdf3258476794784148a6eb65e7', // Sign up for a key: http://embed.ly/pricing 
    selector : {type:'rich'}, 
    preview : { 
    submit : function(e, data){ 
     e.preventDefault(); 
     $.ajax({ 
     dataType: 'script', 
     url: this.form.attr('action'), 
     type: 'POST', 
     data: data 
     }); 
    }, 
    }, 
    autoplay : 0, 
    maxwidth : 400, 
    display : {display : 'rich'} 
}); 

UPDATE

我可以移動選擇()並在窗體中了下來...但不能將它移動到表單之外,或者放在表單之間選民div和表格的結尾。我需要將選擇器移到表單外部,這是問題所在。任何幫助都會很棒。謝謝。

回答

1

的顯示選項有selector選項

docs

顯示
創建的給定對象的飼料項目。
.....
選擇
       告訴創建哪裏飼料項目HTML,預先準備。默認值是#feed。

與樣品:

HTML:

<div id="show_here"></div> 
<form accept-charset="UTF-8" action="private" class="new_comment" data-remote="true" id="new_comment" method="post"> 
    <input class="photo_comm" id="comment_comment" name="comment[comment]" placeholder="add a comment or link..." size="30" type="text" /><span type="text" id="counter">1000</span> 
    <input class="btn btn-primary btn-mini" data-disable-with="Submitting..." name="commit" type="submit" value="Post" /> 
    </form> 

    <!-- Placeholder that tells Preview where to put the loading icon--> 
    <div class="loading"> 
     <img src='http://embedly.github.com/jquery-preview/images/loading-rectangle.gif'> 
    </div> 

JS:

$('#comment_comment').preview({ key:'60f1dcdf3258476794784148a6eb65e7', // Sign up for a key: http://embed.ly/pricing 
    selector : {type:'rich'}, 
    preview : { 
    submit : function(e, data){ 
     e.preventDefault(); 
     $.ajax({ 
     dataType: 'script', 
     url: this.form.attr('action'), 
     type: 'POST', 
     data: data 
     }); 
    } 
    }, 
    autoplay : 0, 
    maxwidth : 400, 
    display : {display : 'rich',selector : "#show_here"} 
}); 
+0

謝謝,由於某種原因,仍然不能得到這個工作。它仍顯示在#comment_comment字段下方。 – user749798

+0

你有什麼地方可以檢查嗎? –

+1

想通了......必須直接編輯jquery.preview.js,因爲現在它只在表單字段(不在其外部)中搜索選擇器。 – user749798

2

我相信你確實有對選擇對象,而不是顯示設置選擇。

嘗試:

... 
selector : {type:'rich', selector: '#show_me'}, 
... 

注意選擇需要生活的表單元素裏面。

+0

仍然不能正常工作... – user749798

+0

任何其他的想法,將不勝感激! – user749798