[英]“Attribute Starts With” selector
Good day! 美好的一天! I am using the jQuery plugin
jstree
together with its search feature. 我正在使用jQuery插件
jstree
及其搜索功能。 It works only for the first "set" of jstree
. 它仅适用于
jstree
的第一个“集合”。 I used incrementing value of div
s and "attribute starts with selector" $('div[id^="jstree"]')
(thanks to a stackoverflow user) but it only searches within the first set. 我使用了
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>
}
Please help me figure this out. 请帮我解决这个问题。 As far as I know the syntax is correct.
据我所知语法是正确的。 Thank you very much!
非常感谢你!
Using jstree()
as a getter might return only 1 instance(first one as in case of any getter methods in jQuery) so try to use a .each() like 使用
jstree()
作为getter可能只返回一个实例(第一个实例,与jQuery中的任何getter方法一样),因此请尝试使用.each()
$('div[id^="jstree"]').each(function () {
$(this).jstree(true).search(v);
})
If there is an existing instance and arg is not a string the instance itself is returned (similar to $.jstree.reference).
如果存在现有实例,而arg不是字符串,则返回实例本身(类似于$ .jstree.reference)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.