$(document).ready(function() {
$("select").kendoDropDownList();
});
$( document ).on( "click", "#new", function(){
$("#container").append('<select><option>New option</option><option>New option 2</option><option>New option 3</option></select>');
});
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.1111/styles/kendo.common-material.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.1111/styles/kendo.material.min.css" />
<script src="//kendo.cdn.telerik.com/2015.3.1111/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2015.3.1111/js/kendo.all.min.js"></script>
<div id="container">
<select>
<option>lorem ipsum</option>
<option>lorem ipsum</option>
<option>lorem ipsum</option>
</select>
</div>
<a href="#" id="new">Add More</a>
I am new to jQuery and KendoUI
我是jQuery和KendoUI的新手
If I am using KendoUI code directly to elements, it is working. But If I create the element dynamically and try to apply, it is not working...
如果我直接使用KendoUI代码到元素,它是有效的。但是,如果我动态创建元素并尝试应用,则它无效...
Please Help!
HTML
<div id="container">
<select>
<option>lorem ipsum</option>
<option>lorem ipsum</option>
<option>lorem ipsum</option>
</select>
</div>
<a href="#" id="new">Add More</a>
SCRIPT
$(document).ready(function() {
$("select").kendoDropDownList();
});
$( document ).on( "click", "#new", function(){
$("#container").append('<select><option>New option</option><option>New option 2</option><option>New option 3</option></select>');
});
1 个解决方案
#1
2
Once you create the elements dynamically, you need to bind the kendoDropDownList
again to the select
tag.
动态创建元素后,需要再次将kendoDropDownList绑定到select标记。
$( document ).on( "click", "#new", function(){
$("#container").append('<select><option>New option</option><option>New option 2</option><option>New option 3</option></select>');
$("select").kendoDropDownList();
});
#1
2
Once you create the elements dynamically, you need to bind the kendoDropDownList
again to the select
tag.
动态创建元素后,需要再次将kendoDropDownList绑定到select标记。
$( document ).on( "click", "#new", function(){
$("#container").append('<select><option>New option</option><option>New option 2</option><option>New option 3</option></select>');
$("select").kendoDropDownList();
});