email - Using flash messages to let users choose to start a function -



i'm new in cakephp.
need know if there's way let app users choose send notification email or not flash message.

i googled didn't find answer... sounds strange because method used in every application...

something like:

    $this->setflash('do wish send notification email?', //yes or no);      //and if choice 'yes'     $this->sendemail(); 

thanks!

for understand, flash in cake just notification purposes.
but, have manage (or similar) using javascript.

from view add function adds "yes or no" buttons on flash div (check out id firebug or that), , bind buttons ajax call sends message.

something like

<script> $(function() {     $('#div_of_the_flash_msg'.append('<div id="yes-button">yes</div> or                                        <div id="no-button">no</div>));      $('#yes-button, #no-button').on('click', function() {         $.ajax(/*parameters ajax call controller $this->sendemail() action*/);      }); }); </script> 

this i've done cases, can't 100% sure it's best way...

it done (maybe, never done it), creating new kind of flash message, flash_send_email class, , in constructor have buttons defined, respective javascript, when setting flash message above

$this->session->setflash('do wish send notification email?', 'flash_send_email'); 

and flash_send_email.ctp (inside elements folder in views) should like

<div class="your-class">     <?php echo $message //that's message send parameter on controller?>     <div id="yes-button">yes</div> or <div id="no-button">no</div> </div> <script>       //same script above handle click situations </script> 

again, second approach haven't tried, same thing bit more reusable if want have kind of message in more 1 view.

all been said, still believe flash messages should use notification purposes, other interaction user can made custom divs, popups, etc etc. give thought, maybe it's not absolutely necessary use flash this.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -