0

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 .

=====

UPDATE

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

2 Answers 2

3

The . needs to be within the quotes:

 $('.second_step').hide();
Sign up to request clarification or add additional context in comments.

2 Comments

And if it still not works then it is conflict with prototype, and to solve it you have to use jQuery('.second_step').hide();
The . outside the quotes was a typo. @Salil I tried this as well and it still did not work. see updated question for console errors.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.