jQuery ui dialog change title after load-callback

后端 未结 5 1147
不知归路
不知归路 2020-12-13 05:09

I like to change the title from an UI Dialog after i have submitted a form in this UI Dialog. So in the callback-function after load i should suggest, but i\'ve

5条回答
  •  感动是毒
    2020-12-13 06:06

    I tried to implement the result of Nick which is:

    $('.selectorUsedToCreateTheDialog').dialog('option', 'title', 'My New title');
    

    But that didn't work for me because i had multiple dialogs on 1 page. In such a situation it will only set the title correct the first time. Trying to staple commands did not work:

        $("#modal_popup").html(data);
        $("#modal_popup").dialog('option', 'title', 'My New Title');
        $("#modal_popup").dialog({ width: 950, height: 550);
    

    I fixed this by adding the title to the javascript function arguments of each dialog on the page:

    function show_popup1() {
        $("#modal_popup").html(data);
        $("#modal_popup").dialog({ width: 950, height: 550, title: 'Popup Title of my First Dialog'});
    }
    
    function show_popup2() {
        $("#modal_popup").html(data);
        $("#modal_popup").dialog({ width: 950, height: 550, title: 'Popup Title of my Other Dialog'});
    }
    

提交回复
热议问题