ajax - CakePHP3.0+Jquery Section Reorderable list -
i developing app in cakephp3.0 makes use of ajax, , it's first go @ this, appreciate feedback on how code written.
this 1 part of larger part of app, before go on rest of ajax other parts of app, want make sure jquery/ajax code optimal , well-structured. red flags going me because see few places code copy/pasted, , makes me think better organized/structured.
here's code view.
here's code controller.
here's looks in action.
i'm looking improvements/optimizations/structuring code can make, both view , controller. there should maybe move model layer? way optimize queries? maybe should implement technique or feature improve performance? plan on adding code editing button ajax , update new code when that. fair ask , posting working code , asking isn't bad thing!
if want structure , organized shuold read good practices jquery, , can more information pactices javascript o jquery want. can result expect, maybe can read clean code.
what have been using myself worked in practice write jquery code in plugin format. way making reusable other projects if needed, cutting down on code duplication, forcing encapsulate change , of becomes open extension closed modification - of great practices make clean code base.
(function($){ var pluginname = function(element) { var elem = $(element); var obj = this; var settings = $.extend({ somesetting: "somevalue" }); this.func1 = function(someargument) { code }; this.func2 = function() { more code }; }; $.fn.pluginname= function() { return this.each(function() { var element = $(this); if (element.data('pluginname')) return; var pluginname = new pluginname(this); element.data('pluginname', pluginname); }); }; })(jquery);
Comments
Post a Comment