Jump to content

How to use Toasty.JS ?


mikromundo

Recommended Posts

Hi, I tried to use toasty.js  but i don´t have success.

In CustomFiles:

files\js\toasty\dist\toasty.css
files\js\toasty\dist\toasty.js


and in the delphi code:

procedure TMainForm.htmlGruposAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);

begin

   if EventName = '_GrupoClique' then
   begin

           UniSession.AddJS( 'var toast = new Toasty();' +

                             'toast.info("Here is some information!");' +

                             'toast.success("You did something good!");' +

                             'toast.warning("Warning! Do not proceed any further!");' +

                             'toast.error("Something terrible happened!");' );

   end;


end;

Somebody help me ?

Link to comment
Share on other sites

  • Administrators

Problem is related to Toasty lib which requires document DOM to be ready when it is loaded.

So you need to lazy load them using defer keyword:

Please remove custom files from ServerModule and add these lines to Main.pas:

initialization
  RegisterAppFormClass(TMainForm);

  UniAddCSSLibrary('toasty/toasty.css', False, [upoFolderFiles, upoPlatformBoth]);
  UniAddJSLibrary('toasty/toasty.js', False, [upoFolderFiles, upoPlatformBoth, upoDefer]);


end.

 

  • Like 1
Link to comment
Share on other sites

I Try all this:

           UniSession.AddJS( //'<script type="text/javascript">'+
                             '$(document).ready(function()'+
                             '{'+
                             'var toast = new Toasty();' +

                             'toast.info("Here is some information!");' +

                             'toast.success("You did something good!");' +

                             'toast.warning("Warning! Do not proceed any further!");' +

                             'toast.error("Something terrible happened!");' +
                             '})' );
                            // '</script>' );

//           UniSession.AddJS( 'toast.info("Here is some information!");' +
//
//                             'toast.success("You did something good!");' +
//
//                             'toast.warning("Warning! Do not proceed any further!");' +
//
//                             'toast.error("Something terrible happened!");' );

Link to comment
Share on other sites

I Try all this:

           UniSession.AddJS( //'<script type="text/javascript">'+
                             '$(document).ready(function()'+
                             '{'+
                             'var toast = new Toasty();' +

                             'toast.info("Here is some information!");' +

                             'toast.success("You did something good!");' +

                             'toast.warning("Warning! Do not proceed any further!");' +

                             'toast.error("Something terrible happened!");' +
                             '})' );
                            // '</script>' );

//           UniSession.AddJS( 'toast.info("Here is some information!");' +
//
//                             'toast.success("You did something good!");' +
//
//                             'toast.warning("Warning! Do not proceed any further!");' +
//
//                             'toast.error("Something terrible happened!");' );

Toasty.rar

Link to comment
Share on other sites

20 minutes ago, mikromundo said:

Toasty.rar

Replace by this:

initialization
  RegisterAppFormClass(TMainForm);

  UniAddCSSLibrary( 'js/toasty/dist/toasty.css', False, [upoFolderFiles, upoPlatformBoth]);
  UniAddJSLibrary( 'js/toasty/dist/toasty.js', False, [upoFolderFiles, upoPlatformBoth, upoDefer]);

end.

 

Link to comment
Share on other sites

On 9/10/2019 at 5:16 PM, belo said:

Flavio,

I made an example adapted to your needs.

Best regards,

Eduardo Belo

Toasty JS Code Sample

Hi, can you help me to use this push.js library on my program?

 

https://pushjs.org/

 

https://github.com/Nickersoft/push.js/archive/v1.0.12.zip

 

Its show a Desktop notifictation by the browser.

I appreciate your help with this, thank you.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...