ajaxSubmitButton() публичный статический Метод

Generates a push button that can submit the current form in POST method.
public static ajaxSubmitButton ( string $label, mixed $url, array $ajaxOptions = [], array $htmlOptions = [] ) : string
$label string the button label
$url mixed the URL for the AJAX request.
$ajaxOptions array AJAX options.
$htmlOptions array additional HTML attributes.
Результат string the generated button.
Пример #1
0
echo TbHtml::ajaxSubmitButton('<i class="icon-fa-save icon-fa-large"></i> Save', 'js:$("#' . $formid . '").attr("action")', array('beforeSend' => 'js:function() {

                // tampilkan loader progress
                $("#loader").show();

                }', 'dataType' => 'json', 'success' => 'js:function(data) {

                // sembunyikan loader progress
                $("#loader").hide();
                    
                    if (data.status=="success") {

                        //tampilkan pesan sukses
                        successMsgBox(data.message);

                        // klik tombol cancel
                        $("#btncancel").trigger("click");

                        // refresh table grid view
                        $.fn.yiiGridView.update("' . $gridviewid . '");

                        // set default action form
                        $("#' . $formid . '").attr("action","' . $defaultaction . '");

                        // set default icon save
                        $("#btncommand").html("<i class=\'icon-fa-save icon-fa-large\'></i> Save");

                    }else if(data.status=="fail"){
						errorMsgBox(data.message);
					}else{

                        $.each(data,function(key,val){

                        // buang class success pada input dan tambahkan class error pada input
                        $("#"+key+"_em_").closest("div").prev().closest("div").removeClass("success").addClass("error");

                        // tampilkan pesan error
                        $("#"+key+"_em_").text(val);
                        $("#"+key+"_em_").show();

                        });
						

                    }
					$("html, body").animate({ scrollTop: 0 }, "slow");   

                 }', 'error' => 'js:function(data) {

                // sembunyikan loader progress
                $("#loader").hide();
				 
                // tampilkan jika status server error
                errorMsgBox("An Error Ocurred Please Try Again");
				$("html, body").animate({ scrollTop: 0 }, "slow");

                }'), array('color' => TbHtml::BUTTON_COLOR_INVERSE, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'id' => 'btncommand'));
Пример #2
0
 public function testAjaxSubmitButton()
 {
     $I = $this->codeGuy;
     $html = TbHtml::ajaxSubmitButton('Submit', '#', array(), array('class' => 'button', 'id' => 'button', 'name' => 'button'));
     $button = $I->createNode($html, 'button[type=submit].btn');
     $I->seeNodeCssClass($button, 'button');
     $I->seeNodeAttributes($button, array('id' => 'button', 'name' => 'button'));
     $I->seeNodeText($button, 'Submit');
 }
Пример #3
0
echo Tbhtml::label('ID Member', 'id_member', array('class' => 'control-label', 'maxlength' => '7'));
?>
    <div class="controls">
        <?php 
$this->widget('yiiwheels.widgets.maskinput.WhMaskInput', array('name' => 'id_member', 'mask' => '9999999', 'htmlOptions' => array('placeholder' => '')));
?>
        &nbsp;&nbsp;
        <?php 
echo TbHtml::ajaxSubmitButton('<i class="icon-fa-search icon-fa-large" style="margin-top:5px;"></i> Search', 'js:$("#form-search-member").attr("action")', array('type' => 'POST', 'data' => 'js:{id_member:$("#id_member").val()}', 'dataType' => 'json', 'success' => 'function(data) {

            if(data){

                $("#member_name").val(data.first_name + " " + data.family_name);
                $("#point").val(data.point);
                disableMember();
                ' . $additionalHandler . '

            }else{

                errorMsgBox("ID Member Not Found");

            }

        }'), array('id' => 'btn-search-member', 'color' => TbHtml::BUTTON_COLOR_INVERSE));
?>
    </div>
</div>

<?php 
echo TbHtml::textFieldControlGroup('member_name', '', array('span' => 5, 'label' => 'Member Name', 'readonly' => 'readonly'));
?>
Пример #4
0
        
      </tbody>
      </table>
     <h5 style="text-align:right;margin-right:120px">Grand Total Point Earned : <span id="grandtotal">0</span></h5>
    </div>

  <div class="span-8" style="margin-left:-2px;margin-top:15px;">
   <div class="form-actions" style="width:730px;">
     <?php 
echo TbHtml::ajaxSubmitButton('<i class="icon-fa-save icon-fa-large" style="margin-top:7px;"></i> Save', 'js:$("#form-addpoint").attr("action")', array('type' => 'POST', 'data' => 'js:$("#form-addpoint").serialize()+"&"+$.param({"id_member":$("#id_member").val().trim()})', 'dataType' => 'json', 'success' => 'function(data){
            
           confirmMsgBox(data);
            

            $("#btncancel").trigger("click");
			$("html, body").animate({ scrollTop: 0 }, "slow");

         }', 'error' => 'function(data){
			
           errorMsgBox("Transaction add point failed, please try again!");
			$("html, body").animate({ scrollTop: 0 }, "slow");
         }'), array('color' => TbHtml::BUTTON_COLOR_INVERSE, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'id' => 'btncommand'));
echo "&nbsp;&nbsp;";
// Tombol untuk batal
echo TbHtml::resetButton('<i class="icon-fa-remove-circle icon-fa-large" style="margin-top:7px;"></i> Cancel', array('color' => TbHtml::BUTTON_COLOR_DEFAULT, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'id' => 'btncancel'));
?>
   </div>
 </div>
<?php 
echo TbHtml::endForm();
?>
Пример #5
0
<?php

/* @var $this UpgradeMembershipController */
Yii::app()->clientScript->registerScript('cleanForm', "\n\n// fungsi untuk membershikan form\nfunction defaultForm(){\n  \$('#form-upgrade-membership').each(function(){\n        this.reset();\n  });\n\n  \$('.alert-error').text('').hide();\n  \$('#new_id_member').prop('readonly',false);\n  \$('#btncommand').prop('disabled',false);\n  \n}\n\n\n\n// Aksi pada saat tombol cancel diklik\n\$('#btncancel').click(function(e){\n  e.preventDefault();\n  defaultForm();\n  defaultFormMember();\n});");
$handler = "\n var type_member = \$('#id_member').val().substring(0,1);\n if (type_member=='2'){\n   \$('.alert-error').text('Member already upgraded').show();\n   \$('#new_id_member').prop('readonly',true);\n   \$('#btncommand').prop('disabled',true);\n }\n";
?>
<p class="alert alert-error" style="display:none"></p>
<?php 
$this->renderPartial('//common/_member', array('additionalHandler' => $handler));
echo TbHtml::formTb(TbHtml::FORM_LAYOUT_HORIZONTAL, $this->createUrl('/transaction/UpgradeMembership/save'), 'post', array('id' => 'form-upgrade-membership'));
?>

<?php 
echo TbHtml::textFieldControlGroup('new_id_member', '', array('span' => 3, 'label' => 'New ID Member'));
?>

<div class="form-actions">
<?php 
echo TbHtml::ajaxSubmitButton('<i class="icon-fa-save icon-fa-large" style="margin-top:7px;"></i> Save', 'js:$("#form-upgrade-membership").attr("action")', array('type' => 'POST', 'data' => 'js:{id_member:$("#id_member").val(),new_id_member:$("#new_id_member").val()}', 'dataType' => 'json', 'success' => 'function(data){
           
            successMsgBox(data.message);
            $("#btncancel").trigger("click");

        }'), array('color' => TbHtml::BUTTON_COLOR_INVERSE, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'id' => 'btncommand'));
echo "&nbsp;&nbsp;";
echo TbHtml::resetButton('<i class="icon-fa-remove-circle icon-fa-large" style="margin-top:7px;"></i> Cancel', array('color' => TbHtml::BUTTON_COLOR_DEFAULT, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'id' => 'btncancel'));
?>
</div>
<?php 
echo TbHtml::endForm();