Reusing window function -- title not working

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    3 posts
    Member since:
    Jan 2017

    Posted 27 Jan Link to this post

    I have multiple buttons for things such as save, save as, new, etc. I wrote the function below so that we could easily call these windows without individually writing JS and HTML for each. Currently everything works except the title. The title displays as the first window opened, if i open Save then close, then open Delete the delete window content is displayed with the Save title. thanks for any help

     

    JS

    $(".kendo--modal").click(function(e) {
        var div     = $(this).attr("data-div"),
            title   = $(this).attr("data-title"),
            content = $(this).attr("data-content"),
            h       = $(this).attr("data-h"),
            w       = $(this).attr("data-w");
       createKendoModal(div, title, content, h, w ) 
    });

     

    HTML

                            <li>
                                <a class="kendo--modal"
                               data-title="Save View As"
                               data-div = "#window"
                               data-content = "/templates/html/modal--save.html"
                               data-h = "800"
                               data-w ="800"
                               >Save As
                               <span class="glyphicon glyphicon-floppy-open"></span>
                               </a>
                            </li>
                            <li>
                               <a class="kendo--modal"
                               data-title="Delete View"
                               data-div = "#window"
                               data-content = "/templates/html/modal--delete.html"
                               data-h = "800"
                               data-w ="800">Delete 
                               <span class="glyphicon glyphicon-trash"></span>
                               </a>
                            </li>

  2. Ryan
    Ryan avatar
    3 posts
    Member since:
    Jan 2017

    Posted 30 Jan Link to this post

    Fresh eyes, revised function works as expected.

    function createKendoModal(div, title, content, h, w ){
        var a = $(div);
     
        a.kendoWindow({
            modal:true,
            actions: [ "Close"],
            visble:false,
            iframe: false,
            content: content
        });
        
       var window = a.data("kendoWindow");
        
        window.setOptions({
          width:  w,
          height: h
        });
        window.title(title).center().open();   
    }
Back to Top