I have some javascript that gets ran 3 times. I noticed it when the confirmation button I had to click cancel 3 times before it disappeared.
Also I am using some tab plugin widget which is prevalant in this file, do you think it could be running the javascript 2 additional times because I am generating 2 tabs?
When should the javascript be output to the DOM? at the end of the page load? or as it goes?
The code for my _view file is:
<?php
$this->breadcrumbs=array(
'Sites'=>array('index'),
$model->name,
);
?>
<h1>Site <?php echo $model->name; ?><br />
<?php echo CHtml::button('Update', array('submit' => array( 'update' , 'id' => $model->id ))); ?>
<?php echo CHtml::button('Create Config', array('submit' => array( 'createconfig' , 'id' => $model->id ))); ?>
<?php echo CHtml::button('Disable', array('submit' => array( 'disable' , 'id' => $model->id ), 'confirm' => 'Are you sure you want to delete this site?')); ?>
</h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'name',
'url',
'ezyuid',
'databasename',
'databaseusername',
'databasepassword',
'sitetype',
'host'
),
));
$ezySiteOauthSetting = $model->getEzySiteOauthSettingFor( "Consumer" , "EzySite" );
$consumerOauthSettings = $ezySiteOauthSetting->threeLeggedOauthSettingObj;
$serverOauthSettings = $model->getServiceOauthSetting();
?>
<h2>Additional Information</h2>
<?php
$tabs = array('Contact'=>$this->renderPartial('/contact/_summaryView', array('model'=>$model->businessContactObj),true,true));
if($consumerOauthSettings)
{
$tabs["Api Setting"] = $this->renderPartial('/oauthSetting/_summaryView', array('model'=>$consumerOauthSettings),true,true);
}
if($serverOauthSettings)
{
$tabs["Xero Integration"] = $this->renderPartial('/oauthSetting/_summaryView', array('model'=>$serverOauthSettings),true,true);
}
$tabs["Users"] = $this->renderPartial('/ezySite/siteViews/_siteUsers', array('model'=>$model),true,true);
$this->widget('zii.widgets.jui.CJuiTabs', array(
'tabs'=>$tabs,
// additional javascript options for the tabs plugin
'options'=>array(
'collapsible'=>true,
'deselectable'=>false
),
));
?>
but for some reason when i check the response from the server it registers 3 functions on the same ID element:
I have no idea why does anyone have any ideas why it gets registered 3 times?
/*<![CDATA[*/
jQuery('body').on('click','#yt0',function(){jQuery.yii.submitForm(this,'/admin/ezySite/update/id/8',{});return false;});
jQuery('body').on('click','#yt1',function(){jQuery.yii.submitForm(this,'/admin/ezySite/createconfig/id/8',{});return false;});
jQuery('body').on('click','#yt2',function(){if(confirm('Are you sure you want to delete this site?')) {jQuery.yii.submitForm(this,'/admin/ezySite/disable/id/8',{});return false;} else return false;});
/*]]>*/
</script>
</div>
<div id="yw2_tab_1"><link rel="stylesheet" type="text/css" href="/assets/8fdc1b82/detailview/styles.css" />
<script type="text/javascript" src="/assets/9ef495a9/jquery.js"></script>
<script type="text/javascript" src="/assets/9ef495a9/jquery.yii.js"></script>
<h2 class="error">Error Connecting To Site(Oauth Settings Have Not Been Created For This Site!)</h2>
<script type="text/javascript">
/*<![CDATA[*/
jQuery('body').on('click','#yt0',function(){jQuery.yii.submitForm(this,'/admin/ezySite/update/id/8',{});return false;});
jQuery('body').on('click','#yt1',function(){jQuery.yii.submitForm(this,'/admin/ezySite/createconfig/id/8',{});return false;});
jQuery('body').on('click','#yt2',function(){if(confirm('Are you sure you want to delete this site?')) {jQuery.yii.submitForm(this,'/admin/ezySite/disable/id/8',{});return false;} else return false;});
/*]]>*/
</script>
</div>
</div>
</div><!-- content -->
</div>
<div id="footer">
Copyright © 2012 by Think Concepts Ltd.<br/>
All Rights Reserved.<br/>
Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a>. </div><!-- footer -->
<div class="clear"></div>
</div><!-- page -->
<div class="clear"></div>
<script type="text/javascript" src="/assets/9ef495a9/jui/js/jquery-ui.min.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('body').on('click','#yt0',function(){jQuery.yii.submitForm(this,'/admin/ezySite/update/id/8',{});return false;});
jQuery('body').on('click','#yt1',function(){jQuery.yii.submitForm(this,'/admin/ezySite/createconfig/id/8',{});return false;});
jQuery('body').on('click','#yt2',function(){if(confirm('Are you sure you want to delete this site?')) {jQuery.yii.submitForm(this,'/admin/ezySite/disable/id/8',{});return false;} else return false;});
jQuery('#yw2').tabs({'collapsible':true,'deselectable':false});
});
/*]]>*/
</script>