1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| function getHotels(id {
if ( comportement 2 ) {
// $("#filtre_hotel"+id).remove()
// $("#filtre_hotel"+id).unbind('change' );
[...]
jQuery.ajax({
type: 'POST',
url: "{{ path('VIHotelBundle_hotel_hotels') }}",
data: {
pays: pays,
},
success: function(data, textStatus, jqXHR) {
var json = jQuery.parseJSON(data);
var content = "<select class='filtre_hotel span12' id='filtre_hotel"+id+"' name='filtre_hotel'><option value='' selected='selected'>Hôtel</option>";
for(i=0;i<json.data.length;i++)
content = content + "<option id='"+json.data[i].presd+"' value='"+json.data[i].id+"'>"+json.data[i].content+"</option>";
content = content + "</select>";
$('#f'+id+' #hotel').html(content); // on place le select
}
});
}
else if ( comportement par defaut ) {
var content = "<select class='filtre_hotel span12' id='filtre_hotel"+id+"' name='filtre_hotel'><option value='' selected='selected'>Hôtel</option>";
{% for hotel in hotels %}
{% if hotel.getPrestataire() != NULL %}
{% set presd = hotel.getPrestataire().getId() %}
{% else %}
{% set presd = "-1" %}
{% endif %}
content = content + "<option id='{{presd}}' value='{{hotel.id}}'>{{hotel.nom}}</option>";
{% endfor %}
content = content + "</select>";
$('#f'+id+' #hotel').html(content); // on place le select
}
$("#filtre_hotel"+id).change(function () {
alert('CHANGE');
});
} |