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

Reusing window function -- title not working

1 Answer 118 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 27 Jan 2017, 10:34 PM

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>

1 Answer, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 1
answered on 30 Jan 2017, 07:15 PM
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();   
}
Tags
Window
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Share this question
or