diff --git a/docs/api/methods.html b/docs/api/methods.html index 4df918d5..cb62c63e 100755 --- a/docs/api/methods.html +++ b/docs/api/methods.html @@ -150,6 +150,7 @@ $.mobile.loadPage( "searchresults.php", {
· Arguments:
See jQuery's data and removeData methods
+ Note: Calling jqmData() with no argument will return undefined. This behavior is subject to change in future versions.
· Also:
When finding elements by their jQuery Mobile data attribute, please use the custom selector :jqmData(), as it automatically incorporates namespaced data attributes into the lookup when they are in use. For example, instead of calling $("div[data-role='page']"), you should use $("div:jqmData(role='page')"), which internally maps to $("div[data-"+ $.mobile.ns +"role='page']") without forcing you to concatenate a namespace into your selectors manually.
diff --git a/js/jquery.mobile.core.js b/js/jquery.mobile.core.js index bd30b2ff..f566dc9c 100644 --- a/js/jquery.mobile.core.js +++ b/js/jquery.mobile.core.js @@ -128,7 +128,11 @@ // Mobile version of data and removeData and hasData methods // ensures all data is set and retrieved using jQuery Mobile's data namespace $.fn.jqmData = function( prop, value ) { - return this.data( prop ? $.mobile.nsNormalize( prop ) : prop, value ); + var result; + if ( typeof prop != "undefined" ) { + result = this.data( prop ? $.mobile.nsNormalize( prop ) : prop, value ); + } + return result; }; $.jqmData = function( elem, prop, value ) {