riot.js 嵌套标签 - 如何 select 内部 html 元素与 jquery?
riot.js nested tags - how can I select an inner html element with jquery?
我有一个包含嵌套标签的 riot 标签...
示例:
<parent>
<!-- dome html here...-->
<child></child> <!-- visually - the child is mounted correctly !-->
<script>
this.on('mount', function(){
$('select').material_select();
});
</script>
</parent>
<child>
<select>
<option values="1">1</option>
<option values="2">2</option>
<option values="3">3</option>
</select>
<script>
this.on('mount', function(){
$('select').material_select();
});
</script>
</child>
现在,我想使用 Materialise 库和 jquery 制作列表
物化设计,例如 http://materializecss.com/forms.html
当 'select' 标签在父标签中时,它通常工作正常!
但是,我找不到在哪里初始化 $('select').material_select();
子标签中的命令,因此子标签中的 select 标签不可见!
我试图在父标签和子标签的 on('mount') 区域内初始化它 - 但它似乎总是 $('select') select或 return 一个空数组 - 有什么想法吗?
您可以尝试强制 children 更新,然后在 child 上调用 on('updated') 事件,因为看起来 [=18] =] 没有准备好 onMount。检查这个例子。
<parent>
<!-- dome html here...-->
<child></child> <!-- visually - the child is mounted correctly !-->
<script>
this.on('mount', function(){
this.update();
});
</script>
</parent>
<child>
<div>
<select>
<option values="1">1</option>
<option values="2">2</option>
<option values="3">3</option>
</select>
</div>
<script>
this.on('updated', function(){
$('select').material_select();
});
</script>
</child>
我有一个包含嵌套标签的 riot 标签... 示例:
<parent>
<!-- dome html here...-->
<child></child> <!-- visually - the child is mounted correctly !-->
<script>
this.on('mount', function(){
$('select').material_select();
});
</script>
</parent>
<child>
<select>
<option values="1">1</option>
<option values="2">2</option>
<option values="3">3</option>
</select>
<script>
this.on('mount', function(){
$('select').material_select();
});
</script>
</child>
现在,我想使用 Materialise 库和 jquery 制作列表 物化设计,例如 http://materializecss.com/forms.html 当 'select' 标签在父标签中时,它通常工作正常!
但是,我找不到在哪里初始化 $('select').material_select();
子标签中的命令,因此子标签中的 select 标签不可见!
我试图在父标签和子标签的 on('mount') 区域内初始化它 - 但它似乎总是 $('select') select或 return 一个空数组 - 有什么想法吗?
您可以尝试强制 children 更新,然后在 child 上调用 on('updated') 事件,因为看起来 [=18] =] 没有准备好 onMount。检查这个例子。
<parent>
<!-- dome html here...-->
<child></child> <!-- visually - the child is mounted correctly !-->
<script>
this.on('mount', function(){
this.update();
});
</script>
</parent>
<child>
<div>
<select>
<option values="1">1</option>
<option values="2">2</option>
<option values="3">3</option>
</select>
</div>
<script>
this.on('updated', function(){
$('select').material_select();
});
</script>
</child>