背景和工具:我如何初始化引導Tagsinput與Ruby on Rails和引導3
我使用Bootstrap Tags Input jQuery plugin使用Rails。
我將這個插件存儲爲vendor/assets/javascripts/bootstrap-tagsinput.js
,它的樣式表爲vendor/assets/stylesheets/bootstrap-tagsinput.css
。
我在數字圖書館的Rails應用中標記了我所有的圖書。
問題:
如果我直接導航到Book#new
或Book#edit
,標籤工作,從項目的演示頁的預期。
但是,如果我通過另一個網頁上的鏈接點擊導航到Books#edit
或Books#new
頁面,然後我的文字輸入格式化爲顯示逗號分隔的字符串science,fiction,good,short
一個典型的HTML文本輸入。
更多信息: 我的輸入是這樣的:
<input class="form-control tagsinput" data-role="tagsinput" id="books_tags"
name="books[tags]" type="text" value="science,fiction,good,short">
的bootstrap-tagsinput.js
文件有這些行,在該文件的底部:這初始化獲取運行
/**
* Initialize tagsinput behaviour on inputs and selects which have
* data-role=tagsinput
*/
$(function() {
$("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput();
});
})(window.jQuery);
似乎通過Rails將它應用到<input>
直接輸入URL的位置,但在通過頁面上的鏈接導航時將其應用於JavaScript。
問題:
我如何初始化從另一個頁面導航時運行?
可能是一個turbolinks問題。 – Swards 2015-07-08 17:10:26