0

I am using the jQuery mobile library (JQM) but am having an issue with a jQuery click event.

By default, JQM uses ajax page transitions to change the DOM. I have a search icon in the header where I want to add a simple click event:

$("#search-toggle").click(function(){
    alert("clicked");
});

This will work only for the home page as subsequent pages are all ajax/dom manipulations.

e.g. It wont work on

www.test.com/#/about

but would work on

www.test.com/about

I want to retain the page transitions (ajax naviagation). How can I however get a simple click event to work with every new 'page'.

A.

1 Answer 1

2

sorted it:

$('#search-toggle').live('click', function() {
    alert("clicked");
});
Sign up to request clarification or add additional context in comments.

2 Comments

in fact needed 'tap' instead of 'click'
If you are using the beta, you may also want to look at the vclick event. It is supposed to automaticly use the most appropriate method depending on the platform in order to react as fast as possible

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.