gameDesign = {
makeSeats: function( num ) { //num = number of seats
var seats = [];
var seat;
var seatWidth = 20;
var seatHeight = 20;
var total = 100;
for( var i=1; i<= num; i++ ) {
seat = $('<div id="seat_'+i+'" class="seats"><div id="index_'+i+'" style="height:100%; width:100%;"><div style="height:100%; width:100%;">Sit Here</div></div></div>');
seat.children(":first").children(":first").click( function(event, i){
var tim = i;
gameDesign.sitOnIndexNo( tim ); });
},
sitOnIndexNo: function( seatIndex ) {
tableFunc.makePlayerSit( RummyGlobal.myInfo.get_jid(), seatIndex );
}
}
问题:单击“坐在这里”时,索引值被传递为未定义..我知道这与闭包有关..但是,我需要进一步的解释和解决方案..