Search code examples
javascriptjquery-mobilemultipage

Jquery mobile change window.location.href to mobile.changePage


I have a short question to JQuery mobile

I Have the following script and want to have a data transition=slide but it is not working with window.location.href. So i want to change it to $.mobile.changePage. But I don't get it.

Here is the script;

var category_data;
$(document).ready(function () {
    $('#search_category_form').bind('submit', function(){
        var form = $('#search_category_form');
        var data = form.serialize();

        $.post('index.html', data, function(){
            category_data = data; 
            window.location.href = 'index.html#search_general';
        });

        return false;
    });        

Thank you for your help


Solution

  • $.mobile.changePage() is now deprecated, however you can change your code to:

    // [deprecated] $.mobile.changePage("index.html#search_general", {transition: "slide"});
    $.mobile.pageContainer.pagecontainer("change", "index.html#search_general", {transition: "slide"});