1

I have a pretty basic mobile html site with javascript search to give it offline search functionality. I put in jquery mobile in order to have a fixed toolbar (using phone gap and the ccs fixed position is not supported). The problem now is that jquery has affected the search functionality by changing the parameters being passed.

You can see the problem when looking at the url.

For example:

If I search for ‘stackoverflow’

The url should be the following: search.html?searWords=stackoverflow

Below is what is created (note the search box value is ‘Search Specs’) search.html?searWords=stackoverflow&Send=Search+Specs

If I take out the ‘Search Specs’ from the search button the code just leaves it out, but I get the same result: search.html?searWords=stackoverflow&Send=

So in a nutshell, the jquery mobile scripts ‘jquery-1.6.4.min.js’ and ‘jquery.mobile.min.js’ are inserting &Send=”value of search button” on the end of the url when the search function is used.

barney
  • 891
  • 1
  • 8
  • 12

1 Answers1

0

This is because jQuery mobile uses AJAX navigation by default, meaning it will intercept all links and forms on all your pages and navigate them using URL's like the one you specified (e.g. page.html#page2.html). This applies to forms as well.

If you can live without this feature, you can turn it off by using ajaxEnabled option.

Zathrus Writer
  • 4,311
  • 5
  • 27
  • 50
  • Thanks for that, its definitely helped, the search function works for the first time (even though the URL is altered as before) and the second time it is back to not working. I've implemented it by creating a new js file called custom and inserting the code in there and then importing it in between where the two jquery js files are imported. Have I implemented this correctly? I would think I haven't considering the URLs are still changed, even though it works the first time... – barney Oct 05 '12 at 11:36
  • so your URLs still get changed to "page1.html#page2.html" ? if it's so, perhaps you can also try to disable `pushStateEnabled` option, which might be the cause – Zathrus Writer Oct 05 '12 at 12:14
  • Yea, it's still adding '&Send=VALUE OF SEARCH BOX' on the end of the URL when I try to search for something.. I'll give pushStateEnabled ago – barney Oct 05 '12 at 13:45
  • well, now that I re-read your question, I did not realize the value of your Send button is a problem, too... is it not possible to you to use the part of URL with your search keyword though? perhaps look at [this SO answer](http://stackoverflow.com/a/5448635/467164) for a little help... – Zathrus Writer Oct 05 '12 at 13:50
  • mmmhhh little over my head! I wonder is it possible just to use the code I need for the nav bar as that's the only feature I am using from jQuery and that would obviously fix the problem.. – barney Oct 05 '12 at 15:37