This is my first attempt to use jquery-mobile and I am trying to pass a value that is stored in the id
of the li
tag generated by Ajax. The li
tag is generated for the Panel widget as you can see below.
var mrn = '123';
$.ajax({
type: "GET",
url: "CFCs/assessment_forms.cfc",
dataType: "json",
data: {
method: "NeroForm_rlu"
},
success: function (data) {
var d = data.items;
var x = '';
for (var i = 0; i < d.length; i++) {
x += '<li data-icon="action" id="formSwitcher_' + d[i].ASSESSMENT_DICTIONARYID + '"><a href="forms.cfm?MRN=' + mrn + '"class="ui-btn ui-btn-icon-right ui-icon-action">' + d[i].FORM_NAME + '</a></li>'
}
$('#leftNav').append(x).listview("refresh");
}
});
I am trying to pass the value generated by the first ajax to this ajax to return information needed to populate the page.
$('li[id^="formSwitcher"]').on("click", function (event) {
var FORMID = $(this);
$.ajax({
type: "GET",
url: "CFCs/assessment_forms.cfc",
dataType: "json",
data: {
method: "FormInstruction_rlu",
AID: FORMID
},
error: function (data) {},
success: function (data) {
var d = data.items;
$('#headerName').html('ACCESSMENT - <b>' + d[0].FORM_NAME + '</b>');
$('#instructions').html(d[0].INSTRUCTION_TOP);
}
});
});
Here is the HTML for the navPanel
<div data-role="panel" data-display="overlay" id="nav-panel" data-theme='a'>
<ul data-role="listview" id="leftNav">
<li data-icon="delete">
<a href="" data-rel="close">Close menu</a>
</li>
<li data-icon="home">
<a href="?MRN=123">Home</a>
</li>
</ul>
</div>
I believe that my selector is not binding so I am a little confused as to how to correct this issue.