Reputation: 2247
I been searching around and trying different methods for quite a while and I can't seem to get the most basic implementation of what I want working.
I simply would like to manipulate a form on the homepage and the first thing I want to do is hide. I don't understand why my syntax is incorrect.
my form-
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :first_name %><br />
<%= f.text_field :first_name %></div>
<div><%= f.label :last_name %><br />
<%= f.text_field :last_name %></div>
<div class="second_step"><%= f.label :profile_name %><br />
<%= f.text_field :profile_name %></div>
<div class="second_step"><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render "devise/shared/links" %>
The simple js in the assets/javascripts/file_name.js
$('.second_step').hide();
My application.js
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require justgage
//= require raphael.min
//= require jquery.purr
//= require best_in_place
//= require_tree .
=====
console errors-
Uncaught SyntaxError: Unexpected token ILLEGAL front.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/assets/rails.j
Upvotes: 0
Views: 372
Reputation: 2247
I found the error.
I had previously removed the .coffee extension on the file name and the first console error above wasn't recognizing the #
in the default rails notes.
I got it working by adding back the coffee extension so as properly identify a #
as a comment.
Everything is working below with the filename front.js.coffee
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
jQuery ->
$('.second_step').hide();
Your answers helped in making sure my syntax was correct and that is was something outside the js. Thanks for your attention.
Upvotes: 0