Announcement

As of November 15, 2014, feeds.adobe.com will no longer be available. To keep up with the latest news from the community, we recommend you follow us on Twitter at @Adobe and @CreativeCloud.

1 | Next Page

Dynamically require controllers using can.route

Aug 4, 2014 9:30 PM
Rating: (Total Clicks 5)

I have a need to dynamically add/require view controllers based on the route’d page in a microsite I’m building. This is a pretty common need, User navigates to Page A, PageAController loads and then loads Page A’s view, User navigates to Page B, PageBController loads and then loads Page B’s view, and so on. While... Read more » (translate)

Writing a CanJS Controller

Aug 4, 2014 9:30 PM
Rating: (Total Clicks 10)

This post will detail how to design and code a controller with CanJS. CanJS Controllers come with a few predefined methods, the most relevant and important are the “setup()”, “init()”, and “destroy()” methods and the “defaults” object. Lets first look at a very basic Controller before we dive into more deatil about the moving parts.... Read more » (translate)

Private members in a module with RequireJS

Aug 4, 2014 9:30 PM
Rating: (Total Clicks 5)

A quick post about how to setup private members in a module with RequireJS. In a previous post, I wrote about how to setup a simple Module using RequireJS. For review, the code of module2.js is below. define(['module1'], function (module1ref) { var module1 = new module1ref(); var returnedModule = function () { this.getModule1Name = function... Read more » (translate)

A cleaner way to write your RequireJS config

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 17)

In my previous post, I wrote about how to setup a simple modular app using RequireJS. In that post I setup my Require config using the standard config that most of us will find on the web. However Id like to introduce a cleaner more concise way to write the same file. Original app.js require.config({... Read more » (translate)

Simple setup with RequireJS

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 13)

Ive been asked a few times about how to setup modules with RequireJS so I figured it would be worth it to put up a simple example of setting up a few modules using RequireJS. The first and most important thing to note is that RequireJS is a dependency management utility, this means we have... Read more » (translate)

Use IIFE (Immediately Invoked Function Expression)

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 12)

IIFEs are an ideal solution for locally scoping global variables/properties and protecting your JavaScript codebase from outside interference (e.g. third-party libraries). If you are writing jQuery code that will be run in many different environments (e.g. jQuery plugins), then it is important to use an IIFE to locally scope jQuery because you can’t assume everyone... Read more » (translate)

How to write a basic jQuery plugin

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 11)

Just a simple template to use for scaffolding a simple jQuery based plugin. Settings are parameters that get passed into the plugin via “options” and are set during the plugins initialization. These options are reference-able and settable. (function($){ $.fn.pluginName = function( options ) { var settings = $.extend({ color: "#556b2f", backgroundColor: "purple" }, options); this.Foo... Read more » (translate)

Global Scope vs. Continental Scope

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 13)

Developers should be familiar with the global scope inside an application. What most developers overlook is that, while jQuery isolates itself in the $.fn scope, as an application grows, this scope becomes a continent with as much pollution as the global scope. Developers should not blindly rely on the isolation that jQuery grants their code... Read more » (translate)

Cache Dom Selectors

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 16)

Cache frequently used elements as local variables, this should be done with great scrutiny as this is a bit of a slippery slope as some developers may want to over use this and effectively load more elements into memory then are actually needed. If this is used correctly and developers hand pick the most frequently... Read more » (translate)

Create Variable References When Looping through Selectors to manipulate a single element

Aug 4, 2014 7:31 PM
Rating: (Total Clicks 14)

If you need to loop through a series of DOM elements to find a specific element that needs to be manipulated, an efficient way to do this is to cache a reference of the selector that will be manipulated prior executing the loop. var $userName = $("#user-name"); $.each($("ul.user-profile-data li"), function() { if(this.isAdmin) { $userName.css("color", "red");... Read more » (translate)

1 | Next Page