Custom action control without going to another page
- Single Page
Posted 25 January 2013 - 16:02 PM
So, im doing a little project that i need to send an email with custom action control for the selected record.
I've added the action_control like this way:
[color=#0000FF]$crud[/color]->[color=#006600]add_action[/color][color=#66CC66]([/color][color=#FF0000]'Email'[/color], [color=#FF0000]''[/color], [color=#FF0000]''[/color],[color=#FF0000]'ui-icon-image'[/color],[color=#000066]array[/color][color=#66CC66]([/color][color=#0000FF]$this[/color],[color=#FF0000]'sendEmail'[/color][color=#66CC66])[/color][color=#66CC66])[/color];
but for every record, it starts this method sendEmail. On the sendMail i have my logic, that is started for every record.
I would like to stay on the same page and click on my action control logic and send my email.
Is that possible?
How can i do that?
Thank You
Posted 25 January 2013 - 23:45 PM
Posted 28 January 2013 - 10:49 AM
That's whats happening. When the page loads, it starts all my email logic. But, i dont want this.
Here is an image
[URL=http://imageshack.us/photo/my-images/521/grocery.png/][IMG]http://img521.imageshack.us/img521/7274/grocery.png[/IMG][/URL]
Uploaded with [URL=http://imageshack.us]ImageShack.us[/URL]
I want to start my logic when the user click on Send Mail. It should even get the selected record, because i need the email from the User.
How can i do that?
I recognized that with add_action i was not able to do this.
Thank you
Posted 28 January 2013 - 11:47 AM
Posted 28 January 2013 - 12:05 PM
you can make a Javascript function which will be do an action after click on the link. you can use a class for those links.
[/quote]
Hi Victor, thank you.
Do you have an example? Only to add the listener and get some value from the record?
Thank you.
Posted 28 January 2013 - 12:15 PM
I never do that )
step 1:
$crud->add_action('send mail', '', '','your_class',array($this,example'));
function example($primary_key , $row)
{
// you can return only id because the JS function only need the "id" to do action
return $primary_key
}
the link was created
step 2:
when user will click on this link the js function get an attribute "href" (in this case it's the "id" ).
then you can use AJAX methods for other actions.
I have no time (I make a project) to make it for you.
Posted 17 January 2015 - 10:22 AM
no,don't work. it point just to example