码迷,mamicode.com
首页 > 编程语言 > 详细

IntraWeb在异步事件中返回javascript 脚本

时间:2015-03-19 12:56:02      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

unit Unit1;

interface

{$DEFINE CODESITE}

uses {$IFDEF CODESITE}CodeSiteLogging, {$ENDIF}
Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWCompButton,
Vcl.Controls, IWVCLBaseControl, IWBaseControl, IWBaseHTMLControl, IWControl,
IWCompMemo, IWCompJQueryWidget, IWCompEdit;

type
TIWForm1 = class(TIWAppForm)
IWMemo1: TIWMemo;
btnMessage: TIWButton;
btnConfirm: TIWButton;
jQueryContentFiles: TIWJQueryWidget;
jQMessageExecuter: TIWJQueryWidget;
jQConfirmExecuter: TIWJQueryWidget;
procedure btnConfirmAsyncClick(Sender: TObject; EventParams: TStringList);
procedure btnMessageAsyncClick(Sender: TObject; EventParams: TStringList);
procedure IWAppFormCreate(Sender: TObject);
private
procedure AJAXConfirm(AParams: TStringList);
public
end;

implementation

{$R *.dfm}

procedure TIWForm1.btnMessageAsyncClick(Sender: TObject;
EventParams: TStringList);
begin
WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(
StringReplace(jQMessageExecuter.OnReady.Text, ‘@Message@‘, ‘显示一个消息对话框就是如此简单!‘, []));
end;

procedure TIWForm1.AJAXConfirm(AParams: TStringList);
var
cResult: string;
begin
cResult := AParams.Values[‘DialogResult‘];
if Length(cResult) > 0 then begin
if cResult = ‘清除‘ then
IWMemo1.Clear
else
IWMemo1.Lines.Add(cResult);
end;
end;

procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
WebApplication.RegisterCallBack(‘AJAXConfirm‘, AJAXConfirm);
end;

procedure TIWForm1.btnConfirmAsyncClick(Sender: TObject;
EventParams: TStringList);
var
cDlgResult: string;
begin
WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(
StringReplace(jQConfirmExecuter.OnReady.Text, ‘@Message@‘,
‘显示一个确认对话框就是如此简单,继续吗?‘, []));
end;


initialization

TIWForm1.SetAsMainForm;

end.

IntraWeb在异步事件中返回javascript 脚本

标签:

原文地址:http://www.cnblogs.com/HuiLove/p/4349914.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!