Re: Javascript Helper modification. Opinions, please.
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 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.
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.
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.
Perfect!! Thanks, Mark :-) On Jul 11, 12:05 pm, mark_story 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 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
Re: Javascript Helper modification. Opinions, please.
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 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
Re: Javascript Helper modification. Opinions, please.
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 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
Javascript Helper modification. Opinions, please.
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