Fancybox Issues an Usage Discussion
#2
Posted 20 July 2010 - 10:04 PM
thiagovidal, on 16 July 2010 - 12:16 PM, said:
would you please describe how to use it.
i add these on my view page, but nothing appear
<div style="display:none"><div id="data">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div></div> <?php $this->widget('application.extensions.fancybox.CFancyBox', array( 'target'=>'data', 'config'=>array( 'scrolling' => 'no', 'titleShow' => false, ), ) ); ?>
what should 'target' refer to?
#3
Posted 21 July 2010 - 01:07 AM
<?php echo CHtml::link("tes","#data", array('id'=>'inline')); ?> <div style="display:none"><div id="data">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div></div> <?php $this->widget('application.extensions.fancybox.CFancyBox', array( 'target'=>'a#inline', 'config'=>array( 'scrolling' => 'yes', 'titleShow' => true, ), ) ); ?>
#5
Posted 22 July 2010 - 05:58 PM
'config' => array(
'onStart'=>"function(){console.log('it works'');}",
'onClosed'=>"function(){alert('it closes');}"
),
However, when Yii generates the script it comes out as:
{
'onStart':'function(){console.log(\'it works\'\');}',
'onClosed':'function(){alert(\'it works\');}'
});
It seems as if Yii is putting quote marks around the function. Is there anyway around this?
Thanks for your help.
#6
Posted 22 July 2010 - 06:34 PM
chazclark, on 22 July 2010 - 05:58 PM, said:
'config' => array(
'onStart'=>"function(){console.log('it works'');}",
'onClosed'=>"function(){alert('it closes');}"
),
However, when Yii generates the script it comes out as:
{
'onStart':'function(){console.log(\'it works\'\');}',
'onClosed':'function(){alert(\'it works\');}'
});
It seems as if Yii is putting quote marks around the function. Is there anyway around this?
Thanks for your help.
Yes dude. I got this issue on one of my projects...
Try use 'js:...' at the beginning of the functions like folow
'onStart':'js:function(){console.log(\'it works\'\');}',
'onClosed':'js:function(){alert(\'it works\');}'
#7
Posted 22 July 2010 - 08:19 PM
thiagovidal, on 22 July 2010 - 06:34 PM, said:
Try use 'js:...' at the beginning of the functions like folow
'onStart':'js:function(){console.log(\'it works\'\');}',
'onClosed':'js:function(){alert(\'it works\');}'
Thanks a lot. Your solution worked like a charm.
#9
Posted 04 August 2010 - 05:48 AM
Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
#11
Posted 04 August 2010 - 09:51 PM
thiagovidal, on 04 August 2010 - 08:30 AM, said:
This is the view where I put the fancybox
<script type="text/javascript"> <?php /* * The javascript for calling ajax * */ echo CHtml::ajax(array('update'=>'#dialog_ground', 'url'=>Yii::app()->createUrl('/Barang/cari', array('inputField'=>'MutasiBarangDet_barang_id')))); ?> </script> <div class="row"> <?php echo $form->textField($model,'barang_id'); ?> <?php echo CHtml::link('Pilih Barang','#dialog_ground',array('id'=>'tampilbarang')); ?> <div class="hidden"><div id="dialog_ground" ></div></div> </div> <?php $this->widget('application.extensions.fancybox.CFancyBox', array( 'target'=>'a#tampilbarang', 'config'=>array( 'scrolling'=> 'yes', ), ) );?>
This is the ajax page that I called, it's view
<?php $dp = $model->search(); $dp->keyAttribute='id'; $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'barang-grid', 'dataProvider'=>$dp, 'filter'=>$model, 'columns'=>array( array( 'name'=>'id', 'value'=>'$data->id', ), 'nama', ), ));?> <div class="row button" align="right"> <?php /* Klik Ok! and it will close the fancybox */ echo CHtml::ajaxButton('Ok!','', array('success'=>'js:function() { var p_sel = $.fn.yiiGridView.getSelection("barang-grid"); if ( p_sel != "") { $("#'.$inputField.'").val(p_sel); $.fancybox.close(); //<--- I want to close at here. but it said "$.fancybox is undefined" } }'),array('id'=>'selectButton')); ?> </div>
Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
#12
Posted 05 August 2010 - 12:21 AM
I need to put the widget to the ajax page become like this :
<?php $this->widget('application.extensions.fancybox.CFancyBox', array( 'target'=>'a#tampilbarang', 'config'=>array( 'scrolling'=> 'yes', ), ) );?> <?php $dp = $model->search(); $dp->keyAttribute='id'; $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'barang-grid', 'dataProvider'=>$dp, 'filter'=>$model, 'columns'=>array( array( 'name'=>'id', 'value'=>'$data->id', ), 'nama', ), ));?> <div class="row button" align="right"> <?php /* Klik Ok! and it will close the fancybox */ echo CHtml::ajaxButton('Ok!','', array('success'=>'js:function() { var p_sel = $.fn.yiiGridView.getSelection("barang-grid"); if ( p_sel != "") { $("#'.$inputField.'").val(p_sel); $.fancybox.close(); } }'),array('id'=>'selectButton')); ?> </div>
By changing this, the fancybox is becomed recognized and it closed successfully
Thanks

Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
#13
Posted 22 September 2010 - 08:52 AM
#14
Posted 07 October 2010 - 01:58 AM
Using this extension i get the following javascript error;
"u is undefined"
Any ideas?
I've put the widget in the view getting rendered.
#15
Posted 08 October 2010 - 04:24 AM
junxiong, on 04 August 2010 - 05:48 AM, said:
I've got the same problem.
The fancybox link:
<?=CHtml::link("jelentem", array('/report/create', 'sid'=>$comment->commentId, 'objtype'=>Report::OBJTYPE_CMT), array('id'=>'reportlink'))?> <?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#reportlink', 'config'=>array( 'scrolling'=>'no', 'titleShow'=>true), ) ); ?>
fancybox content:
<? ... $script=<<<EOD $('#cancellink').click(function() { $.fancybox.close(); }); EOD; Yii::app()->clientScript->registerScript('fclose',$script); ?> <a href="#" onClick="return false;" title="Close window" id="cancellink">mégsem</a>
If I click on cancellink I'll get '$.fancybox is undefined' error message

#16
Posted 13 October 2010 - 01:16 PM
Currently your closing fancybox code :
$.fancybox.close()must be in different file with this code
<?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#reportlink', 'config'=>array( 'scrolling'=>'no', 'titleShow'=>true), ) ); ?>
isn't it?
Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
#17
Posted 03 December 2010 - 10:27 AM
I have a hyperlink as a column value in zii.widgets.grid.CGridView which
has a class activated by fancybox. Works great but when you do a search through
CGridView the fancybox gets destroyed from the hyperlinks in the column value.
Do you know how I can reactivate fancybox after the search returns?
Cheers!
Spiro
#18
Posted 03 December 2010 - 11:49 AM
function fancyboxRearm(target){
$(target).fancybox();
}
or
function fancyboxRearm(){
$(the target).fancybox();
}
on CGridView
afterAjaxUpdate='fancyboxRearm(the target)' //put the target selector...
remember to pass the config parameters again if you have setted on fancybox widget.
got it?
#20
Posted 28 January 2011 - 03:04 AM
Kind Regards,
Gautam Kumar
Hof, Germany