[英]“Attribute Starts With” selector
美好的一天! 我正在使用jQuery插件jstree
及其搜索功能。 它僅適用於jstree
的第一個“集合”。 我使用了div
s的增量值,並且“屬性以選擇器開頭” $('div[id^="jstree"]')
(感謝stackoverflow用戶),但它僅在第一個集合內搜索。
@main(Html(""), nav = "map") {
<a href="@routes.Tags.tree()"> Tree </a> <br><br>
<input type="text" id="plugins4_q" placeholder="Search" class="input"> <br><br>
@for(i <- 0 until first.size()) {
<div id="jstree@i" class="jstree">
<ul>
<li> <span title="@first.get(i).getNotes()"> @first.get(i).getName() </span>
@for(rt <- first.get(i).getRelatedTags()) {
@if(rt.getRelationship().equals("child")) {
<ul>
@multiply(rt)
</ul>
}
}
</ul>
@if(controllers.Tags.getPeers(first.get(i)) != null) {
@for(peers <- controllers.Tags.getPeers(first.get(i))) {
<ul>
<li> <span title="@peers.getNotes()"> @peers.getName() </span>
@for(rt2 <- peers.getRelatedTags()) {
@if(rt2.getRelationship().equals("child")) {
<ul>
@multiply(rt2)
</ul>
}
}
</ul>
}
}
</div> <hr>
}
<script src= '@routes.Assets.at("dist/libs/jquery.js")' type="text/javascript"></script>
<script src= '@routes.Assets.at("dist/jstree.min.js")' type="text/javascript"></script>
<script>
$(function () {
// 6 create an instance when the DOM is ready
$('.jstree').jstree({
"core" : {
"animation" : 0,
"check_callback" : true,
"themes" : { "stripes" : true }
},
"plugins" : [
"contextmenu", "dnd", "search",
"state", "types", "core", "json_data", "ui", "crrm"
]
});
var to = false;
$('#plugins4_q').keyup(function () {
if(to) { clearTimeout(to); }
to = setTimeout(function () {
var v = $('#plugins4_q').val();
$('div[id^="jstree"]').jstree(true).search(v);
}, 250);
});
});
</script>
}
請幫我解決這個問題。 據我所知語法是正確的。 非常感謝你!
使用jstree()
作為getter可能只返回一個實例(第一個實例,與jQuery中的任何getter方法一樣),因此請嘗試使用.each()
$('div[id^="jstree"]').each(function () {
$(this).jstree(true).search(v);
})
如果存在現有實例,而arg不是字符串,則返回實例本身(類似於$ .jstree.reference)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.