#5818: Organize JavaScript into MVC structure
---------------------------+------------------------------------------------
Reporter: colinodell | Type: Enhancement
Status: new | Priority: Low
Milestone: 2.0.0.x | Component: View
Version: | Severity: Trivial
Keywords: | Php_version: n/a
Cake_version: |
---------------------------+------------------------------------------------
There are already a couple 3rd-party ways of doing this, such as Jamal
(http://bakery.cakephp.org/articles/view/another-jamal-helper) and JLM
from the WildFlower CMS
(http://github.com/klevo/wildflower/tree/master/app/plugins/wildflower/jlm)
Essentially, it allows you to divide JavaScripts in a similar MVC
structure. All files are merged and cached, but only the required
functionality is actually executed. So anything within an
'app_controller.js' file would be executed application-wide, while
something like '/forum/view/topic:7' would run the functions specific to
that controller and those for the action.
Although the execution stuff is primarily client-side and framework-
specific, core improvements would be HUGE for facilitating this:
1. An 'official' filenaming convention for seperating JS files (global
ones, components, controller-specific, action-specific, etc)
2. Have the view merge these files together into one JS file. All the
code used to identify each piece would be defined by the user (all the
variables which say 'this block of code should be run here or there).
3. Optional - Have the view also spit out javscript defining variables
like the current action, controller, js components used, etc. The
javascript would then take these variables and execute only the needed
code. This could be the user's responsibility, built into the AJAX
helper, or built into the view.
4. Ability to create different 'merges' based on the prefix or other
criteria. This way, random visitors can't view JS specific to the admin
section.
I know its a long shot, but I strongly believe that Javascript should
follow a similar structure as Cake does with PHP. Otherwise, everything
is lumped together in one folder and difficult to maintain. 3rd party
solutions do work, but there's no standard path structure or core
functionality for organizing/utilizing client-side code in a smart manner
consistent with everything else in CakePHP.
At the very least, I think there should be a standard, MVC-friendly
convention of where to place files.
--
Ticket URL: <https://trac.cakephp.org/ticket/5818>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---