この場合、子ステートメントを実行してasを割り当てるshoppingClickHandler(buyItem)
ことを期待して呼び出しようとしています。switch
feature
buyItem
ただし、エラーが返されますUncaught ReferenceError: buyItem is not defined
。
関数に文字列を送信するだけですか?
function shoppingClickHandler(feature){
var msg;
var itemIdentifier = $(this).parent().attr('class');
switch(feature) {
case buyItem: msg = "You bought Item #" + itemIdentifier;
break;
case tryItem: msg = "You tried Item #" + itemIdentifier + " on";
break;
case suggestItem: msg = "You suggested Item #" + itemIdentifier;
break;
case giftItem: msg = "You gifted Item #" + itemIdentifier;
break;
case add_to_wishlist: msg = "You added Item #" + itemIdentifier + " to your wishlist";
break;
}
makeEntry(msg);
}
//Buy button test
$('.buy').click(function(){
shoppingClickHandler(buyItem);
})
//Try button test
$('.try').click(function(){
})
//Suggest button test
$('.suggest').click(function(){
})
//Gifting button test
$('.gift').click(function(){
})
//Add to wisthlist test
$('.add_to_wishlist').click(function(){
})