Elvex
Elvex

Reputation: 671

Methodological tutorials for jQuery

I spent past week on a jQuery implementation. And retrospectively, though I know how to code, I have to admit I do not know how to organize my code.

There are lots of tutorials explaining how to perform one single operation with jQuery, but what I lack is best practices. The design patterns I use in PHP do not handle concepts such as asynchronous and behaviors. I don't know how to handle the non-linear timeline.

Thus, my jQuery / javascript code gets invariably messy.

Can you give me advice on what to read to remedy this problem ? Books, tutos, etc. are welcome.

Thanks in advance !

Upvotes: 0

Views: 82

Answers (2)

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123397

A good way to organize code is developing with common javascript patterns: an interesting overview by Addy Osmani can be found here: http://addyosmani.com/resources/essentialjsdesignpatterns/book/ .

If one of your biggest problem is to deal with asynchronous task, jQuery offers an implementation of Promises/A pattern provided by Deferred objects since version 1.5, so try to take a look at the online reference (see http://api.jquery.com/category/deferred-object/)

If you're also looking how to organize jQuery code in a plugin then I also suggest this resource: http://jqueryboilerplate.com/

Upvotes: 1

deltanovember
deltanovember

Reputation: 44061

Have a look at Backbone.js. It provides a good way to structure your front end code along lines of MVC.

Upvotes: 1

Related Questions