Search code examples
javascriptjquerytizentizen-web-simulator

.html() not working in tizen


I am trying to change the contents of a div using jquery in Tizen. When I am using .html(htmlString) it is having no effect, whereas if I use .text() the contents are replaced, but HTML is not parsed, as is the behaviour of .text(). Can someone please suggest a workaround/a point where I am missing , so that .html(htmlString) works correctly in Tizen web simulator.

The code is:

<script language="javascript">
function a()
{
var w='<b>'+
restaurantName+
"</b>&nbsp;&nbsp;"+
   '<span class="badge">'+
   userRating+
   "</span>"+
   "<br/>"+
   address.replace("_","<br/>")+
   "<br/>"+
   "<b>Food for 2</b>"+
   "<br/>"+
   price+
   "&#8377;"+
   '<div id="map_canvas">'+
   '</div>';
sessionStorage.setItem("docHTML",w);
location.assign('restaurant.html');

}
</script>

function b() which is called on onload() event of restaurant.html

<script language="javascript">
function b()
{
var contentToSet=sessionStorage.getItem("docHTML");
$("#detailDiv").text(contentToSet);
sessionStorage.removeItem("docHTML");

}
</script>

In both of the pages, jquery is loaded correctly.

Thanks


Solution

  • Found out that sessionStorage was not carrying data to another page/tab. So changed

    sessionStorage.setItem("docHTML",w);
    

    to localStorage.setItem("docHTML",w); in function a() and in function b() retrieved the same with

    var contentToSet=localStorage.getItem("docHTML");
    localStorage.removeItem("docHTML"); 
    

    Thanks a lot everyone.