g:select
request メソッドを呼び出している remoteFunction を起動する onchange イベントを持つものもありますが、コールバック JS 関数は呼び出していません。
これは g:select です:
<g:select id="categories"
name="categories"
from="${Category.findAll('from Category where master is null')}"
noSelection="['':'- Selecione -']" optionKey="id" optionValue="description"
onchange="${remoteFunction(
controller: 'event',
action: 'subCategoriesJSON',
params:'\'id=\' + escape(this.value)',
onSuccess: 'updateSubs(data,textStatus)'
)}"
/>
subCategoriesJSONも呼び出されますが、その後で remoteFunction を呼び出してupdateSubs関数を呼び出す方法はありません。私のページは、head タグで関数のスコープを正しくレンダリングしています。
これは機能です:
<script type="text/javascript">
$(document).ready(function() {
function updateSubs(data, textStatus) {
alert('call me!!!');
var subs = eval("(" + e.responseText + ")");
if (subs) {
$("span#saida").html(subs);
}
}
});
</script>
手がかりは大歓迎です。どうもありがとう!