Asked a similar question as a general topic, but didn't really get an answer that could help. I have the following template
{% block main %}
<div class="col-md-4">
<section class="panel panel-default">
<header class="panel-heading">
<h3 class="panel-title">Terminal</h3>
</header>
<div class="panel-body">
<form action="{{ path('NickAlertBundle_tsubmit') }}" method="post" enctype="multipart/form-data" class="terminalForm" id="terminalForm">
<div class="row">
<div class="col-md-12">
<input type="text" class="addMargin" id="terminal_command" name="terminal_command" placeholder=">">
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-4">
<input type="submit" class="btn btn-default" id="terminal_submit" value="Submit">
</div>
</div>
</form>
</div>
</section>
</div>
<div class="col-md-8" id="terminal-window">
<table class="terminalAvailability">
{% if data is defined %}
{% for info in data %}
<tr>
<td class="flightNumber">{{ info.flightNumber }}</td>
<td class="details">{{ info.from ~ info.to }}</td>
{% for seat, availability in info.seats %}
<td class="seatClass"><span>{{ seat ~ availability }}</span></td>
{% endfor %}
<td class="otherInfo">{{ info.other }}</td>
</tr>
{% endfor %}
{% endif %}
</table>
</div>
<div class="modal"></div>
{% endblock %}
To put it simply, I have a form which takes an command input and when submitted the command is executed against an API. The view is then returned the response which is displayed in the second div. The response looks something like the following
AB123 | LHRLAX | J9 I7 C9 D9 A6 | -0655 0910
--------------------------------------------------------
CF1153 | LHRLAX | I7 J7 Z9 T9 V7 | -0910 1305
--------------------------------------------------------
WF133 | LHRLAX | Y7 T7 J9 T9 C9 | -1500 2206
The Letter/number combination is produced by the seat ~ availability. I need to make these combinations selectable, when selected they can change colour. To do this I simply done
$(function() {
$( ".terminalAvailability .seatClass" ).on( "click", function() {
$(this).find('span').toggleClass('green');
});
});
I am going to provide a submit button (without a form) and when submitted, I need to pass the appropriate data to my ajax function. This data should include all the data on the line with only the selected seat/availability combos. So if I selected J9 and C9 from row 1 and T7 from line 3, the data which is submitted should be
AB123 | LHRLAX | J9 C9 | -0655 0910
--------------------------------------------------------
WF133 | LHRLAX | T7 | -1500 2206
What would be the best way to get the correct data back collected and passed back to my Ajax function (and eventually my controller)?
Thanks