From 79ee6f0d7b94b71d89f30019e66a1746696d5608 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 27 Aug 2010 18:02:11 -0400 Subject: [PATCH] Dialog: When using the title attribute, update the title option. Fixes #5877 - Dialog: when using the title attribute, the title option should be updated. --- tests/unit/dialog/dialog_options.js | 6 +++++- ui/jquery.ui.dialog.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index fb6a28e12..d20f1d764 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -369,7 +369,7 @@ test("stack", function() { }); test("title", function() { - expect(5); + expect(9); function titleText() { return dlg().find(".ui-dialog-title").html(); @@ -377,18 +377,22 @@ test("title", function() { el = $('
').dialog(); equals(titleText(), " ", "[default]"); + equals(el.dialog("option", "title"), "", "option not changed"); el.remove(); el = $('
').dialog(); equals(titleText(), "foo", "title in element attribute"); + equals(el.dialog("option", "title"), "foo", "option updated from attribute"); el.remove(); el = $('
').dialog({ title: 'foo' }); equals(titleText(), "foo", "title in init options"); + equals(el.dialog("option", "title"), "foo", "opiton set from options hash"); el.remove(); el = $('
').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 = $('
').dialog().dialog('option', 'title', 'foo'); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 1f3bd60f0..ff2375164 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -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 || ' ', + title = options.title || ' ', titleId = $.ui.dialog.getTitleId(self.element), uiDialog = (self.uiDialog = $('
')) -- 2.39.5