Yii Framework Forum: Javascript Running 3 Times - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Javascript Running 3 Times Rate Topic: -----

#1 User is offline   Dazza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 16-November 11
  • Location:NZ

Posted 04 December 2012 - 10:06 PM

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 &copy; 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>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users