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

3 posts, 1 answers
  1. Z
    Z avatar
    2 posts
    Member since:
    Dec 2013

    Posted 23 Dec 2013 Link to this post

    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. Answer
    Z
    Z avatar
    2 posts
    Member since:
    Dec 2013

    Posted 23 Dec 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Z
    Z avatar
    2 posts
    Member since:
    Dec 2013

    Posted 23 Dec 2013 Link to this post

    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.
Back to Top