1

我有一个生成按钮的视图:

$view->widget('bootstrap.widgets.TbButton', array(
    'id'         =>   'removeButton',
    'label'      =>  $label,
    'buttonType' => 'ajaxButton', 
  ... etc

生成按钮后,我检查代码,我看到:

<button name="yt0" id="yt0" class="btn btn-primary btn-large" data-loading-text="loading...."  type="button">Add to Cart</button>

为什么名称和 id 都是 yt0 而不是我指定的“removeButton”?

4

2 回答 2

5

它应该是:

$view->widget('bootstrap.widgets.TbButton', array(
  'htmlOptions'   => array('id'=> 'removeButton'),
   etc
于 2013-03-25T13:03:33.523 回答
0

完整示例:

<?php
$this->widget('bootstrap.widgets.TbButton', array(
    'buttonType' => 'submit',
    'type' => $model->isNewRecord ? 'primary' : 'info',
    'label' => $model->isNewRecord ? 'Create' : 'Save',
    'loadingText' => 'Saving...',
    'htmlOptions'   => array('tabindex'=>7, 'id'=>'submit-button', 'class'=>'buttonStateful'),
));
?>


<script>
$('.buttonStateful').click(function() {
    var btn = $(this);
    btn.button('loading'); // call the loading function
    setTimeout(function() {
        btn.button('reset'); // call the reset function
    }, 3000);
});
<
于 2014-07-13T13:53:43.377 回答