{"id":46,"date":"2023-08-25T17:34:44","date_gmt":"2023-08-25T17:34:44","guid":{"rendered":"\/\/api.jquerymobile.com\/1.4\/?p=46"},"modified":"2023-08-25T17:34:44","modified_gmt":"2023-08-25T17:34:44","slug":"jqmData","status":"publish","type":"post","link":"https:\/\/api.jquerymobile.com\/1.4\/jqmData\/","title":{"rendered":"jqmData()"},"content":{"rendered":"<article id=\"jqmData1\" class=\"entry method\"><h2 class=\"section-title\">\n<span class=\"name\">.jqmData()<\/span><span class=\"returns\">Returns: <a href=\"http:\/\/api.jquery.com\/Types\/#Object\">Object<\/a><\/span>\n<\/h2>\n<div class=\"entry-wrapper\">\n<p class=\"desc\"><strong>Description: <\/strong>Store arbitrary data associated with the specified element. Returns the value that was set.<\/p>\n<ul class=\"signatures\"><li class=\"signature\">\n<h4 class=\"name\"><a id=\"jqmData\" href=\"#jqmData\"><span class=\"icon-link\"><\/span>.jqmData()<\/a><\/h4>\n<ul><li><div class=\"null-signature\">This method does not accept any arguments.<\/div><\/li><\/ul>\n<\/li><\/ul>\n<div class=\"longdesc\" id=\"entry-longdesc\">\n\t\t<p>When working with jQuery Mobile, jqmData should be used in place of jQuery core&apos;s <code>data<\/code> method (note that this includes <code>$.fn.data<\/code>, <code>$.fn.removeData<\/code>, and the <code>$.data<\/code>, <code>$.removeData<\/code>, and <code>$.hasData<\/code> utilities), as they automatically incorporate getting and setting of namespaced data attributes (even if no namespace is currently in use).\n\t\t<\/p>\n\t\t<dd>\n\t\t\t<dl>\n\t\t\t\t<dt>Arguments:<\/dt>\n\t\t\t\t<dd>See <a href=\"\/\/api.jquery.com\/jQuery.data\/\">jQuery&apos;s data<\/a> method<br>\n\t\t\t\t<b>Note:<\/b><br>\n\t\t\t\tCalling <code>jqmData()<\/code> with no argument will return <code>undefined<\/code>. This behavior is subject to change in future versions.<\/dd>\n\t\t\t\t<dt>Also:<\/dt>\n\t\t\t\t<dd>\n<p>When finding elements by their jQuery Mobile data attribute, please use the custom selector <code>:jqmData()<\/code>. It automatically incorporates namespaced data attributes into the lookup when they are in use. For example, instead of calling <code>$(&quot;div[data-role=&apos;page&apos;]&quot;)<\/code>, you should use <code>$(&quot;div:jqmData(role=&apos;page&apos;)&quot;)<\/code>, which internally maps to <code>$(&quot;div[data-&quot;+ $.mobile.ns +&quot;role=&apos;page&apos;]&quot;)<\/code> without forcing you to concatenate a namespace into your selectors manually.<\/p>\n<p>One exception to this rule is selecting on namespaced data attributes with URL values, e.g the <code>:jqmData(url)<\/code> that jQuery Mobile uses to track where a page came from. This is because the selector requires a closing parentheses but the parentheses is also valid URL character.<\/p>\n<\/dd>\n\t\t\t<\/dl>\n\t\t<\/dd>\n\t<\/div>\n<\/div><\/article>","protected":false},"excerpt":{"rendered":"<p>Store arbitrary data associated with the specified element. Returns the value that was set.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-methods"],"_links":{"self":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":1,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":47,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/posts\/46\/revisions\/47"}],"wp:attachment":[{"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/api.jquerymobile.com\/1.4\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}