Solution for JS, AJAX, templating for CI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Solution for JS, AJAX, templating for CI (/showthread.php?tid=31339) |
Solution for JS, AJAX, templating for CI - El Forum - 06-15-2010 [eluser]Unknown[/eluser] Someone has to take the rains on this topic... My proposed solution is to take some ideas from smartyCMS approach. by doing such we can keep js logic and CSS logic separate from php logic, and make everything JS framework independent. my ideas would be, if ajax is to be used, simply make a MY_AJAX model that will be loaded to any control that may have ajax, so all Ajax logic and what ever lexicon created can be defind by the user there (or have a few already made for use with JSQuery dojo and so on) then create another directory structor for Views to be such like: Code: Application Example of a Controller: Code: class Customers extends Controller { Example of a Widget(filename: standard_dialogbox.widget) Code: <div id={$css[id]}> Example of Template(filename: add.php): Code: {include: file='header.php'} extremely tired Will edit post with more examples, but i think this gives the direction Solution for JS, AJAX, templating for CI - El Forum - 06-16-2010 [eluser]Myles Wakeham[/eluser] Not sure if there is a question here, or if you want general feedback. I do all of my AJAX requests through one central controller so that I can manage security, XSS filtering, etc. in one place. If I did that in all of my controllers, I'd probably go insane. But it depends on your use-case for this, I guess. Mind you an incoming AJAX request is just another incoming API. What is your strategy when you have to do SOAP, or REST, etc? Do you put that code in all of your controllers as well, or route through one central gatekeeper? Myles |