You want to do some conditional processing depending on if an item or items exist in your DOM (Document Object Model). By default, jQuery doesn't have a function that performs this; however, there is a very simple way to extend jQuery to do so.
By default, the jQuery selectors are pretty advanced. You can select items by classes, ids, attributes, the first, the last, etc… But why stop there? By simply extending jQuery, we can add our own custom selectors to further enhance how we use jQuery. In this example, I will create an extended function called widthOver300 leveraging jQuery's $.extend
To copy/clone an object using jQuery, you will want to leverage the extend function. This function accepts N objects to clone/merge as well as a boolean to indicate whether it should copy recursively or not.
A new feature in CakePHP 2.1 is the ability to make one view extend another view. This is a very neat feature; it's actually quite similar to the concept of Jquery template. The concept behind it is relatively straight forward. You define one view that contains common elements that will be updated in another view. The goal is to avoid duplicating the HTML in a different view.