postMessage
postMessage
Sends a message to this form or to child forms. The receiving form's onMessage handler is invoked.
Parameters
name(string): The message name, which routes to theonMessagehandlerdata(any): The payload passed to the handler (may be null)target(string, optional): The delivery target- null or an empty string → itself
- a FormContainer name → that child form
- comma-separated → several child forms at once
'*'→ broadcast to itself and every embedded form
Returns: None (void)
postMessage vs postMessageAll vs postDelayedMessage vs postMessageToApp
| Method | Delivery scope | Delay |
|---|---|---|
postMessage | Itself, or the child forms you name | None |
postMessageAll | Itself plus every child form (recursive) | None |
postDelayedMessage | Same as postMessage | After the given milliseconds |
postMessageToApp | App level (KAppManager) | 0 or the given milliseconds |
Example
// 자기 자신에게 메시지
$form.postMessage("refresh", null, null);
// 특정 자식 폼에 전달
$form.postMessage("updateStock", { code: "005930" }, "stockChart");
// 여러 자식에 동시 전달
$form.postMessage("resetAll", null, "panel1,panel2");
// 자신 + 모든 임베드 폼에 브로드캐스트
$form.postMessage("themeChanged", { dark: true }, "*");
Related
$form.postMessageAll(name, data)— sends recursively to itself and all children$form.postDelayedMessage(name, data, target, milliSeconds)— sends after a delay$form.postMessageToApp(name, data, milliSeconds)— app-level message