document.ready 内で関数を宣言すると、エラーが発生します。このような
$(document).ready(function(){
function updateSizeOptions()
{
alert("updateSizeOptions");
}
var jGrid = $("#list_main");
jGrid.jqGrid({
url:'db.php?ajaxOp=getData',
colModel:[
$.extend(true,
{ name:'shape_id'
,index:'shape_id'
,edittype:'select'
,formatter:'select'
,editoptions: { onclick:"javascript:updateSizeOptions();" }
}
,{}
]
....
});
エラーが発生します:「ReferenceError:updateSizeOptionsが定義されていません」。
しかし、関数を document.ready の外に移動すると、すべて正常に動作します。
このような
function updateSizeOptions()
{
console.debug("updateSizeOptions");
}
$(document).ready(function(){
var jGrid = $("#list_main");
....
なぜ ?