Re: Javascript Helper modification. Opinions, please.

2010-07-11 Thread Geoff Oliver
Perfect!! Thanks, Mark :-)

On Jul 11, 12:05 pm, mark_story mark.st...@gmail.com wrote:
 This feature was already implemented in 1.3 for Html::script().  It
 has a 'once' option that defaults to true.  As long as you always use
 the same name for a file it will only be included once.

 -Mark

 On Jul 9, 3:05 pm, Geoff Oliver me4t...@gmail.com wrote:



  Hello,

  I've been working with Cake for a few years and I really like it.
  Lately, I've run into a bit of a problem with the way that the
  Javascript Helper handles some things. Specifically, the link
  function and it's $inline parameter. The issue I'm having is this...

  In an element, I am linking in javascript files, but NOT inline -
  $javascript-link('prototype',false);
  In the main layout, I am linking in javascript files, but inline -
  $javascript-link('prototype');

  The problem is that prototype is being included twice. The real
  problem is that I am actually including it twice, but I have no way of
  knowing at that earlier point (in the element) whether it will be
  included later (in the layout) or if it's been included yet, and I
  need it for things to happen in the element, so I don't think I have
  any other choice.

  I understand the behavior is because if you don't pass the $inline
  parameter as false then the Javascript Helper just returns a script
  tag back. If you do pass $inline false then the script is passed to
  the View. The View actually checks to see if it already has that
  script (in $this-__scripts) and if not adds it. This way the script
  will only be included once. I am thinking that it might not be a bad
  idea to add a similar check into the Javascript Helper to prevent the
  same script from being included multiple times.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Javascript Helper modification. Opinions, please.

2010-07-09 Thread Geoff Oliver
Hello,

I've been working with Cake for a few years and I really like it.
Lately, I've run into a bit of a problem with the way that the
Javascript Helper handles some things. Specifically, the link
function and it's $inline parameter. The issue I'm having is this...

In an element, I am linking in javascript files, but NOT inline -
$javascript-link('prototype',false);
In the main layout, I am linking in javascript files, but inline -
$javascript-link('prototype');

The problem is that prototype is being included twice. The real
problem is that I am actually including it twice, but I have no way of
knowing at that earlier point (in the element) whether it will be
included later (in the layout) or if it's been included yet, and I
need it for things to happen in the element, so I don't think I have
any other choice.

I understand the behavior is because if you don't pass the $inline
parameter as false then the Javascript Helper just returns a script
tag back. If you do pass $inline false then the script is passed to
the View. The View actually checks to see if it already has that
script (in $this-__scripts) and if not adds it. This way the script
will only be included once. I am thinking that it might not be a bad
idea to add a similar check into the Javascript Helper to prevent the
same script from being included multiple times.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en