语言

Menu
Sites
Language
How can I recieve 'changePage parameter'

I make some code about popup's parameter..    and This code is works good...     

****

    tau.event.on(btnPopupElement, "tap", function(event){
        popup.option("param1", document.getElementById("txtInput").value);
        popup.open();
    });
    
    divPopupElement.addEventListener("popupafteropen", function(){
        document.getElementById("txtPopup").value = popup.option("param1");
    });

****

 

 I want to make some code about changePage html page to html page('html page') ... 

but,  I don't know about it's way ...

page1.html 

    tau.event.on(document.getElementById("moveNewPage"), "tap", function(event){
        console.log("hi2");
        var options = {PARAM1:document.getElementById("txtInput").value};
        tau.changePage("newpage.html", options);  --> Is this right? or use like jQuery Mobile  *** tau.changePage("newpage.html?param1=test", options);  ***

        // but newpagehtml?param1=test   ==> It seems that this way is not good shape to use... 

    });   

 

page2.html

$("#newpage" ).on( "pageshow" , function(event) {

    // I don't know how can I get txtInput.value from page1.html... It there formal way about file to file parameter send and receive..

   // Is there any example  of  parameter sending and receiving  at file to file .

})

thanks for reading...   

编辑者为: 병옥 이 16 11月, 2014

响应

8 回复
colin Rao

On SDK 2.3, for tau template project, all the pages html are declared in one .html file.

tau.changePage("newpage.html", options); this "newpage.html" should be the object of page2 root div tag, as below:

tau.event.on(document.querySelectorAll("#content1"), "swipeleft", function(event) { _page1_page.prototype.changePage(document.getElementById("page2"), {transition :"flip"}); });

 

about transfer data between two pages, we can use the js prototype inheritance, such as:

in page1 js function:

_page2_page.prototype.tempData={para1:"hello world"};

in page2 js function:

_page2_page.prototype.textinput1.value=tempData.para1;

 

병옥 이

Thanks for response...

pageMove  of div to div is simple .. 

It's no problem....

 

but I want to know  html to html

if the project is big.. and we  make all pages to one html files (consist of may div tags..) ..  ...     that's too slow and not good to manage pages...

jQuery Mobile do not support it also...  but we can parsing it and select the param...

I think tau has the same way  

 

thank you..  

  

Konrad Lipner

Hello,

You have to change way of thinking :) You are not makeing a web page, this is application :) tau.changePage() does not cause page reload. You can keep your parameters simply as global variables.

options passed to changePage are not designed to pass params to page :) Those are options for Page widget like transition. But +1 for creative approach ;)

Konrad.

 

병옥 이

thank you..   I understand..

colin Rao

As below code copied from tau.js, if the type of toPage is string(like the html page name, example "newpage.html"),you can transfer extra data via options.data, example options.data = {param1:value; param2: value}; tau will transfer the options.data to a standard url query parameter and add to the end of the toPage string.

Hope this is useful for you. :)

/**

 * Open a page
 * @method open
 * @param {string|HTMLElement} toPage page url or element
 * @param {Object} options
 * @param {string} [options.type] connection type
 * @param {Object} [options.data] additional url query parameters
 * @param {boolean} [options.showLoadMsg=false] whether to show loading message
 * @param {number} [options.loadMsgDelay] loading message delay in milliseconds
 * @member ns.router.PageExternal
 */
prototype.open = function (toPage, options) {
    var self = this;
    if (typeof toPage === "string") {
        self.loadPage(toPage, options)
            .done(function (url, newOptions, newPage, dupCachedPage) {
                newOptions.duplicateCachedPage = dupCachedPage;
                setTimeout(function () {
                    parentOpen.call(self, newPage, newOptions);
                }, 10);
            })
            .fail(function (url, options) {
                //clear out the active button state
                removeActiveLinkClass(true);

                events.trigger(options.pageContainer, pageEvents.PAGE_CHANGE_FAILED, {});
            });
        return;
    }
    parentOpen.call(self, toPage, options);
};

병옥 이

thank you.  

Good source..    

but I think that tau framework has the simple and formal way.

but it is same ... like jQuery Mobile...  

thank you..

AVSukhov

Hello,

You can use localStorage or sessionStorae to pass parameters.

병옥 이

thank you.    

but I think that tau framework has the simple and formal way.

but it is same ... like jQuery Mobile...  

thanks.