Sasikanth
Sasikanth

Reputation: 3043

How to add focus event to template

I'm trying to add autocomplete functionality to the search box in my home page and I want onfocus event for template to pass this jQuery command source elements. I added jQuery to my meteor app like this mrt add jquery-ui-bootstrap

Template.index.events({
    'focus input.focus-eve':function() {
        $( "#autocomplete" ).autocomplete({
            source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ]
        });
    }
});

EDIT

<input id="autocomplete" class="focus-eve" name="search-txt-box" type="text"  size="80"  placeholder="Search..." />

It is still not working. I added both jQuery and jQuery-UI to my app.

UPDATE

I added the jquery-ui-bootstrap package not the jquery-ui package.

The problem is now solved. Thanks for the help

Upvotes: 0

Views: 2245

Answers (1)

sbking
sbking

Reputation: 7680

Your event is targeting an input element with class focus-eve, but your input in the HTML does not have a class attribute. Try changing your event to 'focus input' or just 'focus'.

Upvotes: 3

Related Questions