I am trying to create dialog in Jquery mobile with dynamic content and in that I am showing a listview. Now when the user clicks an item in the listview, the dialog should close and selected item should be displayed in a textbox. the dialog box is to be displayed when user click in a textbox.
My problem is on first time the dialog is displayed and listview is displayed. But I am not able to get the selected item.
Second time when the user clicks in the same text box the dialog is not displayed.
The code:
<div id="inlinecontent" style="display:none"
data-options='{"mode":"blank","headerText":"Select","headerClose":true,"blankContent":true}'>
<a rel='close' data-role='button' href='#'>Close</a>
</div>
<script type="text/javascript">
document.addEventListener('deviceready', function () {
$('#addadult').click(function(){
var adult = document.getElementById('totaladult').textContent;
alert(adult);
var myInteger = parseInt(adult);
myInteger+=1;
document.getElementById('totaladult').textContent=myInteger;
});
/* $('#listviewfrom').delegate('li', 'click', function () {
$("#txtFrom").val(this.textContent);
$("#txtFrom").trigger('refresh');
$("#popupMenu" ).popup( "close" )
$("#popupMenu ul").hide();
}); */
$('#listviewto').delegate('li', 'click', function () {
$("#txtTo").val(this.textContent);
$("#txtTo").trigger('refresh');
$("#popupMenu1" ).popup( "close" )
$("#popupMenu1 ul").hide();
});
$('#txtFrom').click(function(){
var labels='<ul data-role="listview" data-theme="c" id="listviewfrom" data-filter="true">';
try {
BookingCities = getJsonData();
$.each(BookingCities["BookingCities"], function(i, val) {
labels += '<li data-icon="up"><a href="#" rel="close" onclick="test("'+val.CityName +'")">' + val.CityName + '(' +
val.CityCode + '),' + val.CountryName + ' </a></li>';
});
labels+='</ul>';
$('#inlinecontent ul').listview('refresh');
$("#inlinecontent").html(labels);
$('#inlinecontent ul').show();
$("#inlinecontent").simpledialog2();
}
catch (ex)
{
}
});
$("#txtTo").click(function()
{
var labels='';
BookingCities = getJsonData();
$.each(BookingCities["BookingCities"], function(i, val)
{
labels += '<li data-icon="up"><a href="#">' + val.CityName+'(' +val.CityCode+'),'+ val.CountryName+' </a></li>';
});
});
navigator.splashscreen.hide();
}, false);
</script>
If anyone can help, I shall be thankful