2
爲什麼當我使用"
標誌在data-source
屬性來表示字符串值一切運作良好,但是當我使用'
表示他們引導是認識的第一個字符?Twitter的引導預輸入不具有數據源屬性正常工作
我知道在C#和許多其他語言"
和'
之間的差別是字符和字符串,但它的我第一次看到它是嚴格使用HTML之間的區別是,這裏的情況如果是這樣,爲什麼ISN」 JS中沒有任何錯誤。
<div class="container">
<div class="hero-unit">
<form>
<div>
<label>working typeahead</label>
<input type="text" data-provide="typeahead" autocomplete="off" data-source='["hello","world"]' />
</div>
<div>
<label>not working typeahead</label>
<input type="text" data-provide="typeahead" autocomplete="off" data-source="['hello','world']" />
</div>
</form>
</div>
看到小提琴:http://jsfiddle.net/H4Qmh/4/
您是正確的先生,它被視爲JSON,因此需要雙引號。嘗試[linting](http://jsonlint.com/)這兩種類型的相同數組。 'data-source = [「hello」,「world」]'因爲[HTML屬性值不需要引號](http://www.w3.org/TR/2011/WD-html5-20110525/syntax)。 HTML屬性#0)。 – Terry 2013-04-06 04:41:48