Skip to content

Instantly share code, notes, and snippets.

@tcaddy
Created February 23, 2012 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcaddy/1893758 to your computer and use it in GitHub Desktop.
Save tcaddy/1893758 to your computer and use it in GitHub Desktop.
RoR error_messages_for in jQuery Mobile
// run this after pageload/DOM ready
// this will modify HTML generated by Ruby on Rails :error_messages_for helper method
function jqmify_error_messages_for() {
var sel = $("div.errorExplanation");
if (sel.length>0) {
sel.parent().addClass("ui-body").addClass("ui-body-e");
sel.attr('data-role','collapsible')
.attr('data-theme','e')
.collapsible()
.trigger('expand');
if (sel.find("ul")) {
sel.find("ul")
.attr('data-role','listview')
.attr('data-inset','true')
.attr('data-theme','e')
.listview();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment