TbModal in Yiistrap cannot process onclick button

I would like to have single page CRUD on my application. I want the create and update process to be displayed or processed using modal (TbModal). Below is my code in admin.php




...

<?php

$this->beginWidget('bootstrap.widgets.TbModal', array(

    'id' => 'productModal',

    'header' => 'Add product',

    'content' => $this->renderPartial('_form', array('model' => new Product), true, true),

    'footer' => array(

        TbHtml::button('Save', array('data-dismiss' => 'modal', 'color' => TbHtml::BUTTON_COLOR_SUCCESS, 'icon' => 'plus white',)),

        TbHtml::button('Close', array('data-dismiss' => 'modal', 'icon' => 'remove')),

    ),

));

?>


<?php $this->endWidget(); ?>


<script type="text/javascript">

    function getNewCode() {

        $('#Product_code').val('hello');   // for testing purpose only

    }

</script>




While below is the code of _form.php




<?php

/* @var $this ProductController */

/* @var $model Product */

/* @var $form TbActiveForm */

?>


<div class="form">

    <?php

    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(

        'id' => 'product-form',

        // Please note: When you enable ajax validation, make sure the corresponding

        // controller action is handling ajax validation correctly.

        // There is a call to performAjaxValidation() commented in generated controller code.

        // See class documentation of CActiveForm for details on this.

        'enableAjaxValidation' => false,

    ));

    ?>


    <p class="help-block">Fields with <span class="required">*</span> are required.</p>


    <?php echo $form->errorSummary($model); ?>


    <?php echo $form->textFieldControlGroup($model, 'code', array('span' => 2, 'maxlength' => 15, 'append' => TbHtml::button('&nbsp;' . TbHtml::icon('search white'), array('id' => 'getNewCode', 'color' => TbHtml::BUTTON_COLOR_INFO, 'url' => '#', 'onclick' => 'getNewCode(); return false;')))); ?>


    <?php echo $form->textFieldControlGroup($model, 'name', array('span' => 2, 'maxlength' => 255)); ?>


    <?php echo $form->textFieldControlGroup($model, 'unit', array('span' => 1, 'maxlength' => 50)); ?>


    <?php echo $form->textAreaControlGroup($model, 'description', array('rows' => 1, 'span' => 3)); ?>


    <?php echo $form->textFieldControlGroup($model, 'status', array('span' => 2)); ?>


    <?php $this->endWidget(); ?>


</div><!-- form -->



I am confused, why every time I clicked on the getNewCode button, it does not call the getNewCodeButton() method in admin.php? But if, I make the button call like this,




...

<?php echo $form->textFieldControlGroup($model, 'code', array('span' => 2, 'maxlength' => 15, 'append' => TbHtml::button('&nbsp;' . TbHtml::icon('search white'), array('id' => 'getNewCode', 'color' => TbHtml::BUTTON_COLOR_INFO, 'url' => '#', 'onclick' => 'alert("Hello!"); getNewCode(); return false;')))); ?>

...



I can get alert window which contains is "Hello!".

Any help on this?

TIA

Daniel