0
使用jQuery座位圖表爲機票預訂系統配置Iam。如何限制在jQuery座位圖表中選擇座位的數量
var $cart = $('#selected-seats'),
$counter = $('#counter'),
$total = $('#total'),
sc = $('#seat-map').seatCharts({
map: [
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaa__aaaaaaa',
'aaaaaaaaaaaaaaaaa'
],
seats: {
a: {
price : 50,
classes : 'first-class', //your custom CSS class
category: 'First Class'
}
},
naming : {
top : false,
getLabel : function (character, row, column) {
return firstSeatLabel++;
},
},
legend : {
node : $('#legend'),
items : [
[ 'a', 'available', 'First Class' ],
[ 'a', 'unavailable', 'Already Booked']
]
},
click: function() {
if (this.status() == 'available') {
//let's create a new <li> which we'll add to the cart items
/*$('<li>'+this.data().category+' Seat # '+this.settings.label+': <b>$'+this.data().price+'</b> <a href="#" class="cancel-cart-item">[cancel]</a></li>')
.attr('id', 'cart-item-'+this.settings.id)
.data('seatId', this.settings.id)
.appendTo($cart);*/
$('<span class="badge badge-primary">'+this.settings.label+'</b></span>')
.attr('id', 'cart-item-'+this.settings.id)
.data('seatId', this.settings.id)
.appendTo($cart);
$counter.text(sc.find('selected').length+1);
$total.text(recalculateTotal(sc)+this.data().price);
return 'selected';
} else if (this.status() == 'selected') {
//update the counter
$counter.text(sc.find('selected').length-1);
//and total
$total.text(recalculateTotal(sc)-this.data().price);
//remove the item from our cart
$('#cart-item-'+this.settings.id).remove();
//seat has been vacated
return 'available';
} else if (this.status() == 'unavailable') {
//seat has been already booked
return 'unavailable';
} else {
return this.style();
}
}
});
圖表已成功集成,但我無法找到和文件相關的如何限制客戶的座位選擇數量。即如果顧客輸入票數= 4,則他應該只被允許選擇4個座位。
任何幫助,將不勝感激。提前致謝。