Action url with anchor - ( not a js guru)

in my user_helper.rb
def registration_form
content_for(:ready) do
“window.location = window.location.href +
#register_form’;”
end
end

in my new.html.haml view

  • registration_form

first pass (correct)
http://localhost:3000/en_GB/signup#register_form

subsequent pass ( incorrect … but normal as per the js code)
http://localhost:3000/en_GB/signup#register_form%23register_form

how should I modify the js code to avoid repetition of the anchor, in
Ruby I would write that …

"… unless window.location.href already contains ‘#register_form’ "
" … window.location = window.location.href + ‘#register_form’ "
" … end

but in .js is there any equivalent ?

thanks for your feedback

got the answer from js guru …

use => window.location.href.indexOf(’#register_form’) == -1

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs