I am trying to "encapsulate" a web into a phonegap app, but I am finding a problem. When I make a request to the server it answer me with the html as a text, and I want to take some html elements of this text and append on a div of the index.html of the application. To make this I do so:
jQuery.get(rute, function(htmlTemplate)
{
var data = jQuery(htmlTemplate).find('#wrapper');
//make a small treatment to data, but not yet.
jQuery('body').html(data)
});
I have other application where I do something similar:
function loadPage(placeToLoad, rute, callback)
{
jQuery.get(rute, function(htmlTemplate)
{
var data = jQuery(htmlTemplate).find('#wrapperApp').parent();
if(data.html()!==undefined)
{
placeToLoad.html(data);
data = eraseNoScriptExternalPages(data);
data = eraseStylesExternalPages(data);
data = eraseLinksExternalPages(data);
makeImageScroll(data);
}
else
placeToLoad.html(htmlTemplate);
if (callback!=undefined && typeof(callback)==typeof(Function))
callback();
});
}
In this second case I need to differentiate between the pages that came from a external server (which must be engineered to not cause collateral damage), and local pages.
The case is that the second case works and the first not!!! why!!??
I was trying to make a simple test:
var html = '<head><style> body{background-color:rgba(128,128,128,0.3);}</style> </head> <body> <div id="test">HOLA</div> </body>';
jQuery("#content").html(jQuery(html).find("#test").html());
...but doesn´t work.
I want to choose a specific element to make the small treatment (erase any divs or an aside section).