Skip to content

Commit

Permalink
Dialog: When using the title attribute, update the title option. Fixe…
Browse files Browse the repository at this point in the history
…s #5877 - Dialog: when using the title attribute, the title option should be updated.
  • Loading branch information
scottgonzalez committed Aug 27, 2010
1 parent af9864d commit 79ee6f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/unit/dialog/dialog_options.js
Expand Up @@ -369,26 +369,30 @@ test("stack", function() {
});

test("title", function() {
expect(5);
expect(9);

function titleText() {
return dlg().find(".ui-dialog-title").html();
}

el = $('<div></div>').dialog();
equals(titleText(), "&nbsp;", "[default]");
equals(el.dialog("option", "title"), "", "option not changed");
el.remove();

el = $('<div title="foo"/>').dialog();
equals(titleText(), "foo", "title in element attribute");
equals(el.dialog("option", "title"), "foo", "option updated from attribute");
el.remove();

el = $('<div></div>').dialog({ title: 'foo' });
equals(titleText(), "foo", "title in init options");
equals(el.dialog("option", "title"), "foo", "opiton set from options hash");
el.remove();

el = $('<div title="foo"/>').dialog({ title: 'bar' });
equals(titleText(), "bar", "title in init options should override title in element attribute");
equals(el.dialog("option", "title"), "bar", "opiton set from options hash");
el.remove();

el = $('<div></div>').dialog().dialog('option', 'title', 'foo');
Expand Down
3 changes: 2 additions & 1 deletion ui/jquery.ui.dialog.js
Expand Up @@ -67,10 +67,11 @@ $.widget("ui.dialog", {
this.originalTitle = "";
}

this.options.title = this.options.title || this.originalTitle;
var self = this,
options = self.options,

title = options.title || self.originalTitle || '&#160;',
title = options.title || '&#160;',
titleId = $.ui.dialog.getTitleId(self.element),

uiDialog = (self.uiDialog = $('<div></div>'))
Expand Down

0 comments on commit 79ee6f0

Please sign in to comment.