Duplicate Action Buttons

Hi mates!

At the same “view”, I don’t know how to “copy” or “duplicate” buttons so that have the same action and collect “form” data.

Below I shows you where I want to get.

In the top, "buttons copied" must inherit handlers of "form buttons".

Try using the same class selector for all the buttons and then handle them in your jQuery, e.g. $(".cancelBtn").live(“click”, function(){…}), $(".nextBtn").live(“click”, function(){…}), $(".prevBtn").live(“click”, function(){…}), etc. You may need different id’s for each button to differentiate them inside the function.

Thanks JFReyes,:)

Understood how to handle buttons with jQuery.

Now, how to recover the form data fields with jQuery?

In the "form buttons" (see below) is not necessary recover data because are covered in the form but, how to do this with jQuery for the "copied buttons"?

I thought that would be possible to copy items, for example buttons.




<?php

echo GxHtml::submitButton(Yii::t('app', 'Cancel'),array('name'=>'cancel'));

echo '&nbsp;&nbsp;&nbsp;';

echo GxHtml::submitButton(Yii::t('app', 'Next:   Step 2/'.($numTimetables+1).'  (>>)'),array('name'=>'next'));

$this->endWidget();

?>

To copy elements take a look at jQuery’s clone function. However, I wouldn’t use “submit” buttons for navigation because the form is sent to the server on each click. If you’re writing a multipage wizard to submit just one form only the last button in the last page needs to be of the submit type and it will send all fields in the form. The cancel buttons should be either “reset” or regular types with a Javascript handler; the next and back buttons should be regular buttons that handle navigation through Javascript as well.

Thanks for request Reyes,

In that case, is necessary to clone the form buttons for update operation. Why? Because the view displayed is so long and then, user should be going down page to submit.

As far as “wouldn’t use ‘submit’ buttons”… Fortunately, is not a multiuser operation, and only one person manages this operation… anyway, I keep in mind your advice for other situation.

Thanks again, I will use jQuery clone function!