This is a migrated thread and some comments may be shown as answers.

SPA drop down list from view template not working on re-render

2 Answers 14 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Z
Top achievements
Rank 1
Z asked on 23 Dec 2013, 07:41 AM
Running build v2013.3.1119.  The drop down list functions normally when it is first displayed, but after switching out views with a re-render of the view the drop down list becomes disabled and cannot be clicked on or accessed.  I also noticed that a submit button loses its click event hander when the template is re-rendered.

Here is a jsfiddle example that replicates the issues: http://jsfiddle.net/markm1/x5q24/

I have tried different ways of creating the drop down, including using mvvm and the results are the same.  Any ideas?

Here is the html:
<script id="index1" type="text/x-kendo-template">
    <select id="ddMatter1" name="ddMatter" >
        <option>Select 1...</option>
        <option value="type-1">1</option>
        <option value="type-2">2</option>
    </select>   
<input id="search" name="search" type="submit" value="Search"/>
</script>
<div id="app"></div>
<br/><br/><br/>
<p>click render to break things</p>
<input id="render" type="submit" value="Render"/>

And here is the script:
var index1 = new kendo.View('index1');
$("#app").html(index1.render());
$("#ddMatter1").kendoDropDownList();
$("#search").click(function () { alert('search'); });
// render the view again to break things
$("#render").click(function () { $("#app").html(index1.render());
alert("Now the drop down does not work and the search button is no longer wired up")}); 

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 23 Dec 2013, 11:18 AM
Hi,

Current scenario is not working because you are simply replacing the HTML which unbounds the wired event. 
Instead please consider using the following approach:


Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Z
Top achievements
Rank 1
answered on 23 Dec 2013, 05:32 PM
OK, that makes sense.  It is working a little differently than I was expecting.  Looks like I still have some learning to do.  Thanks for the prompt reply.
Tags
SPA
Asked by
Z
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Z
Top achievements
Rank 1
Share this question
or