TypeError: The result of the expression 'toPage.data ("page")' [undefined] is not an object - in jQuery mobile

I am using jQuery Mobile Split view in my application. It works great. I need to split the view for only some pages, and for regular pages I set data-role="page" . When I try to load regular pages other than split pages, I get the following error:

 "TypeError: Result of expression 'toPage.data( "page" )' [undefined] is not an object." 

In jquery.mobile-1.0.js line number 2458

 toPage.data( "page" )._trigger( "beforeshow", null, { prevPage: fromPage || $( "" ) } ); 
+4
source share
2 answers

i ran into the same problem. this does not happen for all pages, only a couple of them. this is not a solution, but a temporary workaround. Just try to catch this statement: P your application will work fine. it will not affect the operation of your application. Tell me if you can find the real problem behind this error.

+1
source

The changePage parameter must be a DOM object. Therefore, if you want to use changePage manually, you must provide it with a DOM object. I suggest you use them to work to get the page DOM object

 var allPage = $('div.ui-page');//get the DOM of the all pages on the html page console.log(allPage); var mainPage = allPage.prev("div#Mainpage");//find to get the previous page console.log(mainPage); //input for changePage must be DOM object --> so how we get DOM object?, see some previous lines we'll see the solution $.mobile.changePage(mainPage, {transition: "slide", reverse: true}, true, true); 

As you can see: in the first line, I get the whole DOM object from my page. in the next line, I search in the previous DOM objects to find the page I need. and finally you can give it the changePage function. It will work just fine.

0
source

Source: https://habr.com/ru/post/1402843/


All Articles