{"id":596,"date":"2022-08-30T15:03:59","date_gmt":"2022-08-30T15:03:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/how-to-change-ajax-forms-transition-in-jquery-mobile-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:03:59","modified_gmt":"2022-08-30T15:03:59","slug":"how-to-change-ajax-forms-transition-in-jquery-mobile-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-change-ajax-forms-transition-in-jquery-mobile-collection-of-common-programming-errors\/","title":{"rendered":"How to change Ajax forms transition in jQuery Mobile?-Collection of common programming errors"},"content":{"rendered":"<p>Is there a way to change the transition of the Ajax forms in jQuery mobile ? For now, when I submit a form, if the validation (server-side) is successful, it slides to the \u00ab success page \u00bb, that&#8217;s ok but if the form is invalid, it slides to the same form with fields errors\u2026 It&#8217;s kinda weird \ud83d\ude42 I&#8217;d like to make it fade instead\u2026<\/p>\n<p>I know I can override ajax submission but it&#8217;s better with, though\u2026<\/p>\n<p><strong>* Edit *<\/strong><\/p>\n<p>I found that we can override the default transition type, so I think I could make it with the default transiton set to &#8216;fade&#8217; and specify the transition for the other links but it does&#8217;t work, here is the code, not sure what&#8217;s wrong\u2026<\/p>\n<pre><code>\n\n\n<\/code><\/pre>\n<p>in <em>custom.js<\/em><\/p>\n<pre><code>$(document).live(\"mobileinit\", function(){\n    $.mobile.defaultTransition: 'fade'\n});\n<\/code><\/pre>\n<p>No error, nor 404.<\/p>\n<ol>\n<li>\n<p>Supposedly you can add the <code>data-transition<\/code> attribute to the form tag, like this:<\/p>\n<pre><code>\n  ...\n<\/code><\/pre>\n<p>But I have yet to see it work effectively.<\/p>\n<h2>FIXED<\/h2>\n<p>Well, I&#8217;ve submitted a fix request on github, but what you have to do is alter the jQuery Mobile source:<\/p>\n<pre><code>line 2159 of the alpha-3 release:\n    $.mobile.changePage({\n            url: url,\n            type: type,\n            data: $(this).serialize()\n        },\n        $(this).attr('data-transition'),  \/\/ this used to be *undefined* just like the next parameter\n        undefined,\n        true\n    );\n<\/code><\/pre>\n<p>then you can just use <code>data-transition=\"fade\"<\/code> in your form tag.<\/p>\n<\/li>\n<li>\n<p>I just use data-transition=&#8221;none&#8221; and it seems to work. Maybe this is something that it was fixed. I am using 1.0a4.1<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:07:01. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Is there a way to change the transition of the Ajax forms in jQuery mobile ? For now, when I submit a form, if the validation (server-side) is successful, it slides to the \u00ab success page \u00bb, that&#8217;s ok but if the form is invalid, it slides to the same form with fields errors\u2026 It&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-596","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=596"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/596\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}