fail to set session storage in dynamic list view by using json & ajax
Hi all,
I am trying to show a listview using json data. i want to set url for each row using sessionStorage() but i was failed to set
my code is
- <!DOCTYPE html>
- <html>
- <head>
- <title>categories</title>
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0">
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
- <!--<link rel="stylesheet" href="main.css" />-->
- <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
- <script src="load.js" type="text/javascript" ></script>
- </head>
- <body>
- <!-- Main Page -->
- <div data-role="page" data-theme="a" id="cList">
-
- <!-- Logo -->
-
- <div data-role="header">
- <a href="#" data-rel="back" data-add-back-btn="true" data-back-btn-text="Back" data-direction="reverse">back</a>
- <h1>categories</h1>
- </div>
-
-
- <div data-role="content" id="categoryList">
- <!-- No results warning (initially hided) -->
- <div id="notfound"><h5>no results found</h5></div>
- <!-- Results container -->
- <ul id="catResults" data-role="listview" data-inset="true" data-filter="true" data-theme="c">
- </ul>
- <!-- Ajax loader -->
- <div id="loader"><h4>Loading...</h4></div>
- </div>
-
- </div>
- <!-- end Main Page -->
- <script>
-
-
- $( document ).delegate("#cList","pagebeforecreate", function() {
-
- alert('catgories page');
- categories();
-
- });
-
-
- </script>
-
-
- <!-- end Detail Page -->
- </body>
- </html>
- function categoryCallback(data) {
- alert('under catgory call back');
- //Checks if search have results
-
- //Ajax loader is hided
- $("#loader").hide();
- $("#catResults").empty();
- alert('before foreach');
- alert('data is'+data);
- //<ul id="catResults" data-role="listview" data-inset="true" data-filter="true" data-theme="c">
- var ouput = '';
- // ouput+=
- $.each(data, function(index, category) {
- //Stores element id
- //alert('be foreach');
- var catgoryId = category.id;
-
- //alert('category id is'+catgoryId);
- //Change the default 'not found' poster
- var catgoryName = category.cName;
- catCouponUrl="http:\/\/www.morenmoredeals.com\/ws\/api\/Json.php?data=cByCategoryNew&id=";
- //
- //$("#catResults").append('<li><a onclick="'+
- // 'sessionStorage.setItem(\"key\",'
- // +encodeURIComponent(catCouponUrl)+
- // category.id+
- // '");" href="#">'+
- // '<h3>'+category.cName+'</h3>'+
- // '</a></div></li>');
- ouput += '<li><a onclick="sessionStorage.setItem("key","';
- //ouput+=catCouponUrl+category.id;
- ouput+="http://www.morenmoredeals.com/ws/api/Json.php?data=cByCategoryNew&id=";
- // ouput+=catCouponUrl;
- //ouput+=category.id;
- ouput+=");";
- ouput+='<h3>';
- ouput+=category.cName;
- ouput+='</h3>';
- ouput+='</li>';
-
-
- });
- ouput+='</ul>';
- $('#catResults').html(ouput).listview("refresh");}
code is working fine but i am getting output html as follows
- <a json.php?data="cByCategoryNew&id=);<h3" api="" ws="" www.morenmoredeals.com="" key","http:="" onclick="sessionStorage.setItem(" class="ui-link-inherit">Apparel/Clothing</a>
but my intesion is to get output like this
- <a onclick="sessionStorage.setItem("key","http:www.morenmoredeals.com/ws/api/Json.php?data=cByCategoryNew&id=100"); class="ui-link-inherit">Apparel/Clothing</a>
my problem is i fail to set function and url properly
can any body please help me
thanks and regards
vara prasad