herculanojs Posted October 6, 2016 Share Posted October 6, 2016 Hello friends. Necesito call showmask via JS code in situations which do not own visual component that will trigger by a user click. Does anyone know tell me how could run it. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 7, 2016 Administrators Share Posted October 7, 2016 unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniEdit, uniButton; type TMainForm = class(TUniForm) UniButton1: TUniButton; UniEdit1: TUniEdit; procedure UniEdit1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); private { Private declarations } public { Public declarations } end; function MainForm: TMainForm; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, Unit1; function MainForm: TMainForm; begin Result := TMainForm(UniMainModule.GetFormInstance(TMainForm)); end; procedure TMainForm.UniEdit1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'CR' then begin Sleep(1000); // your big task here! end; end; initialization RegisterAppFormClass(TMainForm); end. object MainForm: TMainForm Left = 0 Top = 0 ClientHeight = 396 ClientWidth = 616 Caption = 'MainForm' OldCreateOrder = False MonitoredKeys.Keys = PixelsPerInch = 96 TextHeight = 13 object UniEdit1: TUniEdit Left = 184 Top = 216 Width = 121 Hint = '' Text = 'UniEdit1' TabOrder = 0 ClientEvents.ExtEvents.Strings = ( 'keypress=function keypress(sender, e, eOpts)'#13#10'{'#13#10' if (e.getKey(' + ') == 13 ) {'#13#10' sender.showMask('#39'Please wait'#39');'#13#10' ajaxRequ' + 'est(sender, '#39'CR'#39', []); '#13#10' }'#13#10'}') OnAjaxEvent = UniEdit1AjaxEvent end end Link to comment Share on other sites More sharing options...
zilav Posted October 7, 2016 Share Posted October 7, 2016 I use this simple approach for custom events In JS code MainForm.form.showMask('Loading...'); ajaxRequest(...); In ajax event try ... finally UniSession.AddJS('MainForm.form.hideMask();'); end; Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 7, 2016 Administrators Share Posted October 7, 2016 I use this simple approach for custom events In JS code MainForm.form.showMask('Loading...'); ajaxRequest(...); In ajax event try ... finally UniSession.AddJS('MainForm.form.hideMask();'); end; Actually you don't need to call hideMask() Link to comment Share on other sites More sharing options...
herculanojs Posted October 7, 2016 Author Share Posted October 7, 2016 fine, tanks brothers Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 7, 2016 Administrators Share Posted October 7, 2016 Actually you don't need to call hideMask() On a 2nd thought. If object sending the ajaxRequest is different from object which is displaying the mask then you need to call hidemask(). Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now