Re: Javascript Helper modification. Opinions, please.

2011-12-09 Thread gremlin
Or - load your jquery with the normal html tag and not the helper and
reserve your use of the helper to include scripts that are strictly on
a controller/action/view basis.
Then your jquery can be the very first thing loaded always - also you
could modify the helper by passing in a configurable list of script
names or regular expressions to check against so you could whitelist
or blacklist certain scripts from even being includable (if you
include jquery manually, and have a blacklist including a regex that
catches the jquery filename you can make the helper simply refuse to
output that script tag )

On Dec 8, 9:47 pm, Benjam Welker benjamwel...@gmail.com wrote:
 It also seems that scripts added in the default layout or through elements
 that are included in the default layout don't have their scripts added to
 the queue at all.

 I was going to try adding all the default scripts in via an element, but
 they just get ignored.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Javascript Helper modification. Opinions, please.

2011-12-08 Thread Benjam Welker
One issue that I'm having, is that if a script is included in the default 
layout in the HEAD tag above the $scripts_for_layout, with the default 'inline' 
= true, and then again in a view (or element, or whatever) with 'inline' 
= false, The HtmlHelper does not recognize that the script in question has 
already been loaded, and proceeds to load another version of it.

This is troublesome, and doubly so for scripts like jQuery, where if it 
gets loaded again, it loses all previously loaded plugins.

How can I stop Cake from loading already loaded scripts that were loaded 
directly in the header of the layout?

Is this a bug?  Or deliberate?

I've tried a few things to fix this without editing core files, but they 
all have their various issues.

   1. Setting 'inline' = false on scripts loaded in the views, the scripts 
   that should have been loaded via the layout template (which have 'inline' 
   = true) get moved down in the queue, setting jQuery below some of it's 
   plugins (which only get loaded in the layout, therefore don't get moved 
   down, and get loaded inline as expected).
   2. Setting all scripts in the layout to 'inline' = false, seems to lose 
   all scripts that are added in the layout template. Only loading scripts 
   that were added in the views. Not sure why.
   3. Setting 'once' = false on the layout scripts, then the view 
   instances of the scripts get loaded as well.  It seems that 'once' = 
   false bypasses the storage of the script name into the 
__includedScriptsarray.

Any other methods for getting this to work as I'm expecting?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Javascript Helper modification. Opinions, please.

2011-12-08 Thread Benjam Welker
It also seems that scripts added in the default layout or through elements 
that are included in the default layout don't have their scripts added to 
the queue at all.

I was going to try adding all the default scripts in via an element, but 
they just get ignored.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Javascript Helper modification. Opinions, please.

2010-07-11 Thread mark_story

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


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


Re: Javascript Helper modification. Opinions, please.

2010-07-09 Thread nurvzy
That's a good idea, although the JavascriptHelper is deprecated now.
As such, I would put in a feature request for the JsHelper via
lighthouse.

Nick

On Jul 9, 1: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