2

I have been struggling with this all day: I am using jquery, jquery ui, and jquery mobile. I am creating a simple autocomplete input field. It works when I first load http://localhost/m/ , but when I click around and navigate back to the page with the autocomplete, it doesn't work anymore. That page is http://localhost/m/#/m/index.php. Also, when I start with localhost/m/#/m/index.php, autocomplete does not work. The following code is in my .

$('div').live('pagebeforeshow',function(event){
var availableTags = [
                "ActionScript",
                "AppleScript",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            "COBOL",
            "ColdFusion",
            "Erlang",
            "Fortran",
            "Groovy",
            "Haskell",
            "Java",
            "JavaScript",
            "Scheme"
        ];
$( "#tags" ).die();
$( "#tags" ).autocomplete({
    source: availableTags
    });
});

Does anyone have any idea what is going on here? Much appreciated!

Lundin
  • 195,001
  • 40
  • 254
  • 396
Justin
  • 21
  • 1
  • How is the JavaScript in your question wrapped? Mobile can be be picky on _when_ the page is ready. – andyb Jul 15 '11 at 07:44
  • $(document).ready().... and i've tried putting the script in multiple places... in the head, in the body. – Justin Jul 15 '11 at 15:45
  • Does my answer http://stackoverflow.com/questions/6549014/jquery-mobile-beta-can-no-longer-use-data-role-header/6549539#6549539 help as [there doesn't seem to be a document.ready for jQuery.mobile](http://markdalgleish.com/2011/04/document-ready-for-jquery-mobile/) – andyb Jul 15 '11 at 16:13
  • good point - i took out $(document).ready() but it still doesn't work. i guess my fundamental question is - does anyone have a simple working example of a jquery mobile page with jquery ui autocomplete? – Justin Jul 15 '11 at 17:58
  • Could you edit the question and add a [SSCCE](http://sscce.org/) demonstrating your problem? – andyb Jul 17 '11 at 06:00
  • jQuery mobile (JQM) and jQuery UI are not supposed to work well together. If you need a simple example of autocomplete with JQM, try http://jquerymobile.com/demos/1.3.0-rc.1/docs/demos/widgets/autocomplete/ – Harry Apr 07 '13 at 08:11

0 Answers0