0

I am trying to get auto complete to work using the jquery UI, but it doesn't seem to be triggered.

The hashtag.js.coffee is being loaded into the application.js. There are no errors being thrown in the console either

hashtag.js.coffee

$('.swag_text_field').autocomplete
source: ['foo', 'food', 'four']

view

<%= form_tag hashtags_path, class: "search-form", remote: true do %>
            <div class="input-prepend input-append">
            <span class="add-on swag">#</span>

            <%= text_field_tag :hashtag, nil, class: "span4 swag_text_field", id:"appendedPrependedInput" %>

            <%= submit_tag "VS!", class: "btn add-on-right swag_button" %>
            <% end %>

1 Answer 1

3

Turns out coffee script is white space sensitive.

   jQuery ->
        $('.swag_text_field').autocomplete
            source: ['foo', 'food', 'four']
Sign up to request clarification or add additional context in comments.

2 Comments

worked like a magic , upvoted for it . But why it's so . can you explain it . i just made 1 indent/tab in my code and it worked ;(
the answer means that you should indent a tab space on line after the autocomplete method

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.