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 tried and googled without result.
Has anyone an idea?
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 tried and googled without result.
Has anyone an idea?
Using dialog methods:
$('.selectorUsedToCreateTheDialog').dialog('option', 'title', 'My New title');
Or directly, hacky though:
$("span.ui-dialog-title").text('My New Title');
For future reference, you can skip google with jQuery. The jQuery API will answer your questions most of the time. In this case, the Dialog API page. For the main library: http://api.jquery.com
.option()
method which takes an object as well, see options(options)
here: api.jqueryui.com/dialog/#method-option –
Lynching I have found simpler solution:
$('#clickToCreate').live('click', function() {
$('#yourDialogId')
.dialog({
title: "Set the title to Create"
})
.dialog('open');
});
$('#clickToEdit').live('click', function() {
$('#yourDialogId')
.dialog({
title: "Set the title To Edit"
})
.dialog('open');
});
Hope that helps!
An enhancement of the hacky idea by Nick Craver to put custom HTML in a jquery dialog title:
var newtitle= '<b>HTML TITLE</b>';
$(".selectorUsedToCreateTheDialog").parent().find("span.ui-dialog-title").html(newtitle);
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'});
}
Even better!
jQuery( "#dialog" ).attr('title', 'Error');
jQuery( "#dialog" ).text('You forgot to enter your first name');
id
of yoru dialog is #dialog
. –
Ina © 2022 - 2024 — McMap. All rights reserved.