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


    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.

  • 相关阅读:
    电脑操作记录
    【转】XCode快捷键
    【转】iOS开发入门:Xcode常用快捷键
    【转】Android ProgressDialog的使用2
    【转】Android ProgressDialog的使用
    【转】在VMware中安装OS X Yosemite
    【转】VMware Workstation 11 永久激活码key 非注册机
    【转】Xcode 7 真机调试详细步骤
    【转】Xcode7真机调试iOS应用程序
    【转】iOS开发Xcode7真机调试教程
  • 原文地址:https://www.cnblogs.com/HuiLove/p/4349914.html
Copyright © 2020-2023  润新知