html+= "<li><a href=''><span>"+data.cars[d][i].model+" </span><p>"+data.cars[d][i].doors+"</p></a></li>";
$('li a').on('click', function(event){
$('#model').text($(this).children('span').text());
$('#door').text($(this).children('p').text());
})
How to Separate Row Values in Text View's in PhoneGap?
-
16-07-2023 - |
Question
I have parsed the json data in TableView. The code for table view is given below-
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css">
</head>
<body>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Cars</h1>
<a href="levels.html" data-role="button" data-inline="true" data-mini="true">Back</a>
</div>
<div data-role="main" class="ui-content" style="margin-top:-20px;">
<h2></h2>
<ul data-role="listview" id="listid">
</ul>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript">
$(function()
{
$.getJSON("json/details.json",function(data)
{
var html="";
for(var d in data.cars)
{
for(var i in data.cars[d])
{
html+= "<li><a href=''>"+data.cars[d][i].model+" <p>"+data.cars[d][i].doors+"</p></a></li>";
}
}
$("#listid").append(html);
})
.done(function()
{
$("#listid").listview().listview("refresh");
});
});
</script>
</div>
</body>
</html>
Now, When i click on first row, it should separate the Indica and Four Doors in Two test View, Like this-
Please give me suggestion. Thanks in Advance !!
Solution
OTHER TIPS
You could pass the text in a function on onClick. Example:
<a onClick="cars(carName, carDoors)"/>
function cars(name, doors){
$('#carView').html(carName); //set the text for the car view
$('#doorView').html(carDoors);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow