dmindex.pas 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. unit dmindex;
  2. {$mode ObjFPC}
  3. interface
  4. uses
  5. SysUtils, Classes, web, htmlfragment, bootstrapwidgets, Rtl.TemplateLoader,
  6. Rtl.HTMLActions;
  7. type
  8. { ThfHello }
  9. ThfHello = class(THTMLFragment)
  10. bmHello: TBootstrapModal;
  11. alMain: THTMLElementActionList;
  12. actShowModal: THTMLElementAction;
  13. tlDialogs: TTemplateLoader;
  14. procedure actShowModalExecute(Sender: TObject; Event: TJSEvent);
  15. procedure bmHelloHide(Sender: TObject; El: TJSHTMLElement; Values: TStrings
  16. );
  17. procedure DataModuleHTMLLoaded(Sender: TObject);
  18. private
  19. public
  20. end;
  21. var
  22. hfHello: ThfHello;
  23. implementation
  24. {$R *.lfm}
  25. { ThfHello }
  26. procedure ThfHello.actShowModalExecute(Sender: TObject; Event: TJSEvent);
  27. begin
  28. bmHello.show;
  29. end;
  30. procedure ThfHello.bmHelloHide(Sender: TObject; El: TJSHTMLElement;
  31. Values: TStrings);
  32. Var
  33. aName,aFirstname,aLastName : String;
  34. begin
  35. if Assigned(el) and SameText(el.id,'btnSave') then
  36. begin
  37. aFirstName:=Values.Values['FirstName'];
  38. aLastName:=Values.Values['LastName'];
  39. if (aFirstName='') and (aLastName='') then
  40. aName:='Anonymous person'
  41. else
  42. aName:=aFirstName+' '+aLastName;
  43. window.alert(aName+', you confirmed the dialog with the save button')
  44. end
  45. else
  46. window.alert('You canceled the dialog');
  47. end;
  48. procedure ThfHello.DataModuleHTMLLoaded(Sender: TObject);
  49. begin
  50. alMain.Bind;
  51. end;
  52. end.