<table>
<tbody data-im-control="post">
<tr>
<td><input type="text" data-im="item@product_id" size="2"></td>
<td><input type="text" data-im="item@qty" size="2"></td>
<td><button data-im-control="post">追加</button></td>
</tr>
</tbody>
</table>
INTERMediatorOnPage.processingBeforePostOnlyContext = function(targetNode) {
// ボタンを押した直後で、データベース処理の前に実行される
// trueを返すとデータベース処理に移行する。falseを返すとデータベース処理はせずにキャンセル
};
INTERMediatorOnPage.processingAfterPostOnlyContext = function(targetNode, returnValue) {
// データベース処理の後に実行される
};
INTERMediatorOnPage.processingBeforePostOnlyContext = function(targetNode) {
var mainContext = IMLibContextPool.contextFromName("invoice");
var nodeId = INTERMediatorOnPage.getNodeIdFromIMDefinitionOnEnclosure("invoice@id", mainContext.enclosureNode);
var idValue = document.getElementById(nodeId).value;
INTERMediator.additionalFieldValueOnNewRecord = {};
INTERMediator.additionalFieldValueOnNewRecord['item'] = {field: "invoice_id", value: idValue};
return true;
};
INTERMediatorOnPage.processingAfterPostOnlyContext = function(targetNode, returnValue) {
var subContext = IMLibContextPool.contextFromName("item");
INTERMediator.constructMain(subContext);
};
<table>
<tbody data-im-control="post">
<tr>
<td><select data-im="item@product_id"><option data-im="product@id@value product@name"/></select></td>
<td><input type="text" data-im="item@qty" size="2"></td>
<td><button data-im-control="post">追加</button></td>
</tr>
</tbody>
</table>