zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    springMVC总结
    spring总结
    dubbo文档
    mysql集群
    JVM-优化
    JVM-GC日志打印
    JVM-垃圾回收
    JVM-问题定位示例
    C++11
    《疯狂的程序员》
  • 原文地址:https://www.cnblogs.com/HuiLove/p/4349914.html
Copyright © 2011-2022 走看看