I've been trying to nest an if else statement inside a snippet of existing code I have that creates a summary section at the bottom of the page when a user clicks on a row from a table on the same page.
//Register to selectionChanged event to hanlde events
selectionChanged: function () {
//Get all selected rows
var $selectedRows = $('#PeopleTableContainer').jtable('selectedRows');
$('#SelectedRowList').empty();
if ($selectedRows.length > 0) {
//Show selected rows
$selectedRows.each(function () {
var record = $(this).data('record');
$('#SelectedRowList').append(
'<b>ISO Name</b>: ' + record.ISO_Name + '<br /><br />',
'<b>Abstract</b>: ' + record.Abstract + '<br /><br />',
'<b>Problem Description</b>: <pre>' + record.Problem_Description + '</pre><br /><br />'
);
});
} else {
//No rows selected
$('#SelectedRowList').append('No row selected! Select rows to see here...');
}
},
What I'm trying to accomplish is to nest an if statement that will run if a certain string is found within the Problem_Description field. What changes are <pre>
tags, which I need in fields that contain the string "VEID", but not in fields that don't have this string.
As an example I've trying to simply nest an if statement where Problem_Description is so -
//Register to selectionChanged event to hanlde events
selectionChanged: function () {
//Get all selected rows
var $selectedRows = $('#PeopleTableContainer').jtable('selectedRows');
$('#SelectedRowList').empty();
if ($selectedRows.length > 0) {
//Show selected rows
$selectedRows.each(function () {
var record = $(this).data('record');
$('#SelectedRowList').append(
'<b>ISO Name</b>: ' + record.ISO_Name + '<br /><br />',
'<b>Abstract</b>: ' + record.Abstract + '<br /><br />',
**if ("CVIED" in record.Problem_Description);
{'<b>Problem Description</b>: <pre>' + record.Problem_Description + '</pre><br /><br />'}
else {<b>Problem Description</b>:' + record.Problem_Description + '<br /><br />}
);**
});
} else {
//No rows selected
$('#SelectedRowList').append('No row selected! Select rows to see here...');
}
},
I've tried creating two different statements all together which doesn't seems to work either, is there any I can accomplish this? Thank you.
*I've only ever programmed in python,so java script, and it variants are fairly new to me, so I apologize if my questions seems really simple.
Aucun commentaire:
Enregistrer un commentaire