Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// inicio de archivo: protected/views/algo/_subvista1.php ////
- <h1>Una subvista que se comunica con su vista maestra</h1>
- <button id='boton-dentro-de-iframe'>Click Me</button>
- <?php
- Yii::app()->getClientScript()->registerScript("algun_id",
- "
- $('#boton-dentro-de-iframe').click(function(){
- // dispara un evento a la ventana dueña del iframe:
- var nombre_evento = 'boton-presionado';
- parent.postMessage(nombre_evento,'*');
- });
- ",CClientScript::POS_LOAD);
- //// fin de archivo ////
- //// inicio de archivo: protected/views/algo/vistamaestra.php ////
- <?php
- $subvista1_url = CHtml::normalizeUrl(array('subvista1'));
- ?>
- <h1>Una vista maestra que incluye a otras mediante IFRAME</h1>
- <iframe id='iframe1' src='{$subvista1_url}'
- style='width: 800px; height: 350px;'></iframe>
- Yii::app()->getClientScript()->registerScript("algun_id",
- "
- window.addEventListener('message',function(e){
- var nombre_evento = e.data;
- alert('evento enviado por iframe: '+nombre_evento);
- });
- // si se quiere reiniciar la vista1 se invoca a:
- var _reiniciar_vista1 = function(){
- document.getElementById('iframe1')
- .contentDocument.location.reload(true);
- }
- // ejemplo: _reiniciar_vista1();
- ",CClientScript::POS_LOAD);
- //// fin de archivo ////
Advertisement
Add Comment
Please, Sign In to add comment