From da24d2779637a6ee01542b1e34b764a88023d1dd Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 15 Mar 2011 15:00:20 -0400 Subject: [PATCH] Adding in a new :jqdata() selector for filtering data- attributes within the proper jQuery Mobile namespace. --- js/jquery.mobile.core.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/jquery.mobile.core.js b/js/jquery.mobile.core.js index e4f9e9a4..952dd061 100644 --- a/js/jquery.mobile.core.js +++ b/js/jquery.mobile.core.js @@ -109,4 +109,15 @@ }, 150 ); } }); + + // Monkey-patching Sizzle to filter the :jqdata selector + var oldFind = jQuery.find; + + jQuery.find = function( selector, context, ret ) { + selector = selector.replace(/:jqdata\((.*)\)/g, "[data-" + (jQuery.mobile.ns || "") + "$1]"); + + return oldFind.call( this, selector, context, ret ); + }; + + jQuery.extend( jQuery.find, oldFind ); })( jQuery, this );