• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add JS to my anchor_popup

Hi - I want to resize and reposition my popup window using the anchor_popup(). I am guessing that I need to add the JS window.open method to the head section of my target page. I have experimented and googled but so far I have failed totally to get it to work. JS is my weakness for sure. I'm totally unclear how to get the array attributes from anchor_popup to be applied to the window.open.

Can someone more experienced than me please help me out .. or even put me ot of my misery with some sample code ?

Many Thanks !!

[eluser]Cristian Gilè[/eluser]
Check the user guide: http://ellislab.com/codeigniter/user-gui...elper.html

When you echo the anchor_popup, the window.open JS statement is embedded in the anchor link. You have only to set the array attributes for the anchor_popup method:

$atts = array(
              'width'      => '800',
              'height'     => '600',
              'scrollbars' => 'yes',
              'status'     => 'yes',
              'resizable'  => 'yes',
              'screenx'    => '0',
              'screeny'    => '0'

echo anchor_popup('path/to/your/controller/method', 'Click Me!', $atts);

Hi thanks Cristian - I had tried that approach already, however when I attempted to change the width and height it had no effect. It delivered the default attributes. Don't I needed some JS on my view ??

Ok - I have it working .. THANKS !

[quote author="vincej" date="1338785240"]Ok - I have it working .. THANKS ! [/quote]

Care to share how you did it?

Hi DNC - sure, like many students of CI/PHP I am prone to making dumb mistakes. After I had added the attributes array I was testing my popup by clicking the link - guess what ... I only got the defaults .. ie no change.

Then I realised that clicking the link is not enough - you have to reload the page which *contains* the array and the anchor link - bingo, it worked. A big DUH for me.

Of course, when using the anchor_popup() I assume you have to have JS loaded in the system already - which I already had.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.