我有一個函數需要將參數市場傳遞給函數freeSample,但我似乎無法將其設置爲參數。請花一點時間查看我的代碼,並幫助我瞭解如何在freeSample函數中將市場作爲參數。CoffeeScript函數參數
(freeSample) ->
market = $('#market')
jQuery('#dialog-add').dialog =
resizable: false
height: 175
modal: true
buttons: ->
'This is Correct': ->
jQuery(@).dialog 'close'
'Wrong Market': ->
market.focus()
market.addClass 'color'
jQuery(@).dialog 'close'
更新:這是目前我正在嘗試轉換爲CoffeeScript的JavaScript。
function freeSample(market)
{
var market = $('#market');
jQuery("#dialog-add").dialog({
resizable: false,
height:175,
modal: true,
buttons: {
'This is Correct': function() {
jQuery(this).dialog('close');
},
'Wrong Market': function() {
market.focus();
market.addClass('color');
jQuery(this).dialog('close');
}
}
});
}
你能否也提供你的JS代碼? – Subodh