From da89fcbc07f236d43e6a1edd98603beea6e245b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 21 Jan 2012 08:45:41 -0500 Subject: [PATCH] Widget: Added _getCreateEventData(). Fixes #8045 - Widget: Ability to provide event data for create event. --- tests/unit/widget/widget_core.js | 15 +++++++++++++++ ui/jquery.ui.widget.js | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 2e55ad703..df83abe91 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -261,6 +261,21 @@ test( "._getCreateOptions()", function() { $( "
" ).testWidget({ option2: "value2" }); }); +test( "._getCreateEventData()", function() { + expect( 1 ); + var data = { foo: "bar" }; + $.widget( "ui.testWidget", { + _getCreateEventData: function() { + return data; + } + }); + $( "
" ).testWidget({ + create: function( event, ui ) { + strictEqual( ui, data, "event data" ); + } + }); +}); + test( "re-init", function() { var div = $( "
" ), actions = []; diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 5c8560bfd..ad03e6f44 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -204,10 +204,11 @@ $.Widget.prototype = { } this._create(); - this._trigger( "create" ); + this._trigger( "create", null, this._getCreateEventData() ); this._init(); }, _getCreateOptions: $.noop, + _getCreateEventData: $.noop, _create: $.noop, _init: $.noop, -- 2.39.5