Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A way to reuse JavaScript code inside my MVC framework [closed]

I'm developing a web community in CakePHP and started to have doubts about using jQuery to provide useful widgets around the views when needed.

For example, I've wrote a jQuery plugin which searches the data inside specific input text, asks to my database and get the results handled with events.

Basically the plugin is perfect for simple applications but it's basically useless for a community where I use it almost in all the views and every time handling it with different events and methods, making it with huge event declarations and very annoying to be debugged.

This is just the first of a lot of plugins I'll need to use inside the community, because I would like to have a lot of widgets all around user actions in the site without refreshing the page for small changes.

After some search I thought to solve my problem by implementing a JavaScript MVC based framework inside my web application.

After a read of this article I thought Ember.js would be a nice solution but it seems to be a JavaScript full Application which should be used entirely all over the website than a JavaScript library built to support my CakePHP app (also an MVC framework)

Also does exists some specific framework useful to build reusable widgets?

like image 313
vitto Avatar asked Jun 16 '26 00:06

vitto


1 Answers

If I had to do something similar, I'd implement the JS lib for use on layout level (instead of specific view). I'd pick 2 cases - one with the simplest scenario and one with a more complex use case. Then note what are the similarities and differences. That at least would give me a baseline for decision if it's worth pursuing further and would expose the extent to which it will have to be complex.

like image 75
vector Avatar answered Jun 17 '26 14:06

vector