JavaScript as a condition to load Rails form?

LyndaLee

New Member
I have a form with a Jquery plugin requirement that creates a form input field with a type of Facebook-autocomplete kind of style:\[code\]<%= javascript_include_tag "form_prettify_library" %><div class="box"> <ul id="first_form" class="tagit"> <li class="prettify-new"></li> </ul> <%= form_for @brand do |f| %> <%= f.hidden_field :tag_list, :value =http://stackoverflow.com/questions/9428542/> @brand.tags_from(current_user).join(", "), :id => "mytaglist" %> <%= f.submit "Add tags" %> <%= f.error_messages %> <% end %></div>\[/code\]It works well, however without JavaScript the form doesn't work because the form above only has a hidden_field and no visible entry field (the entry field is created by the plugin inside of the tags), and I need this to work without JavaScript on mobile devices. Is there any way to show the code above if JavaScript is loaded, otherwise the code below will be displayed if it isn't?\[code\]<div class="box"> <%= form_for @brand do |f| %> <%= f.label :tag_list, "Your tags" %> <%= f.text_field :tag_list, :value =http://stackoverflow.com/questions/9428542/> @brand.all_tags_list %> <%= f.submit"Add tags" %> <% end %></div> \[/code\]
 
Top