Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call from javascript #5

Open
dadinugroho opened this issue May 30, 2015 · 5 comments
Open

Call from javascript #5

dadinugroho opened this issue May 30, 2015 · 5 comments

Comments

@dadinugroho
Copy link

dadinugroho commented May 30, 2015

I use ajax to send form and get response in form of JSON. The response contains type (success/error), title, and message. How could I call the growl from javascript given I have title and message?

Thanks a lot.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@fxdyx
Copy link

fxdyx commented Dec 5, 2015

@dadinugroho, I understand that issue opened 8 month ago, but this answer may be useful.

  • You need register assets in your view
// @app/views/site/page.php

use kartik\growl\GrowlAsset;
use kartik\base\AnimateAsset;
GrowlAsset::register($this);
AnimateAsset::register($this);
  • Then in ajax response include whatever you whant to pass in growl.
// @app/controllers/AjaxController.php

public function actionBar()
{
  // some stuff you handle
   return [
       'success'  => true,
       'growl' => [
           'title' => '<h3>Success!</h3>',
           'message' => '<p>Some message</p>',
           'type' => 'success',
           // other params
       ],       
   ];
}
  • On ajax success/error passing params.
$.notify(responseData.growl.title, responseData.growl);

@dadinugroho
Copy link
Author

Thank you for your answer. My further question is where I should put $.notify ?

I am using renderAjax from johnitvn ajaxcrud extension.

@omarOrtiz123
Copy link

You should put it where you handle your ajax response, it can be in done() promise

@ainonovo
Copy link

ainonovo commented Feb 25, 2018

how about other params?

 'growl' => [
       'title' => '<h3>Success!</h3>',
       'message' => '<p>Some message</p>',
       'type' => 'success',
       // other params
   ],    

'message' - not work for me

'delay' => 5000, - work

where you can read the rest of the parameters?

@omarOrtiz123
Copy link

omarOrtiz123 commented Feb 26, 2018

var growlOptions = { title: 'foo', message: 'bar', };var growlSettings = { placement: { from: "bottom", align: "right"}, type: 'danger', }; $.notify(growlOptions, growlSettings);

This is working for me, doc link: http://bootstrap-growl.remabledesigns.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants