Reputation: 3238
According to FullCalendar docs there is possible to pass parameters to JSON feed. I'd like to pass as parameters some HTML elements values. I don't undestand why but some of them passing successfully however others are not. For example this one passing:
<select id="ticketsnumber" class="form-control" name="pax">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
But this one not:
<select id="optionsfrom" class="form-control" name="depplace">
<option value="" selected="">Откуда...</option>
<option class="bold info" name="Country" value="460">Россия</option>
<option name="City" value="1">Москва (MOW)</option>
<option class="bold info" name="Country" value="359">Болгария</option>
<option name="City" value="539">ВАРНА ()</option>
<option class="bold info" name="Country" value="359">Болгария</option>
<option name="City" value="559">СОФИЯ ()</option>
<option class="bold info" name="Country" value="84">Испания</option>
<option name="City" value="19">Барселона (BCN)</option>
<option class="bold info" name="Country" value="7">США</option>
<option name="City" value="95">Нью-Йорк (N.Y)</option>
<option class="bold info" name="Country" value="53">Тайланд</option>
<option name="City" value="220">Бангкок (BKK)</option>
</select>
This is how I call events feed:
eventSources: [
{
url: "@Url.Content("~/Home/GetQuota")",
data: {
pax: $("select[name='pax'] option:selected").val(),
fromtype: $("select[name='depplace'] option:selected").attr("name"),
fromcode: $("select[name='depplace'] option:selected").val(),
totype: $("select[name='arrplace'] option:selected").attr("name"),
tocode: $("select[name='arrplace'] option:selected").val(),
airservice: $("input[name='tariffs']").val()
},
type: "POST",
error: function () {
alert('Ошибка получения квот!');
}
}
]
Upvotes: 2
Views: 3097
Reputation: 14163
What you want is the Dynamic data parameter (2nd from bottom)
Your code above is getting $("select[name='depplace'] option:selected").val()
when the fullcalendar is initialized instead of every time the JSON feed is queried.
url: "@Url.Content("~/Home/GetQuota")",
data: function() { //runs every time the JSON script is called.
return {
pax: $("select[name='pax'] option:selected").val(),
fromtype: $("select[name='depplace'] option:selected").attr("name"),
fromcode: $("select[name='depplace'] option:selected").val(),
totype: $("select[name='arrplace'] option:selected").attr("name"),
tocode: $("select[name='arrplace'] option:selected").val(),
airservice: $("input[name='tariffs']").val()
};
}
Upvotes: 3