How to integrate a jQuery plugin into Yii Framework

I have been studying up on Yii framework as a potential alternative to Zend. It has its pluses and minuses. Yii framework comes with jQuery included at the core. It was ridiculously easy to download a jQuery plugin, drop it in as a black box, follow the instructions for the front end, and it just works. I used the star-rating plugin. If you have a rating for a piece of content represented as a number such as 3.642/4 on a scale of 0-4, it is much more Web 2.0 friendly if you represent that graphically. Star-rating uses pimped up radio buttons to represent this number as five fractional stars. It also does the front end of dynamic interactive ratings, and as soon as I get my ajax back-end working on that I’ll post that too. Since the actual code being typed in is illegible in the video, I have included it in this article.

Continue Reading…

Listen to this post Listen to this post

Dojo toolkit wrapper

I’ve been finding lately that my simplest blog posts grow the longest tails. So here is one for all you dojo toolkit users or wannabe’s. I started seeing the following in dojo scripts that I hadn’t seen before, and couldn’t find any specific comments about it.

;(function(d,$){ /* your code here */})(dojo, dojo.query)

The leading semicolon is a fudge in case you’re using the build tools and glomming multiple files and the one ahead of yours forgot its trailing semicolon. An extra semicolon won’t hurt anything.
In my world (linux conf files), a leading semicolon often is a comment marker, so even though I know that is not the case in ECMAscript (AKA Javascript), it still caused me to do a double take.

The purpose of the anonymous function is to parameterize dojo and dojo.query so that you can use d to refer to dojo, and the JQuery/prototype style $ as shorthand for queries. That’s all there is to it. It also serves to point up a less used way to both define and call a function all in one bang.

Listen to this post Listen to this post
|