jQuery serializeObject 0.1

I found myself in a situation recently where I wanted to have access to variables that would have been posted, in a the same structure as if the form had been posted and returned the JSON, using this jQuery plugin and Douglas Crockford’s JSON library, I think I’ve done it!

You can download the script here and there’s a demo here.

CakePHP: Select Box Pagination

Using CakePHP’s built in pagination system has saved me so much time in my current day job, but the latest designs I’m working on have drop-down box style pagination, as it’s possible to get many pages of results.

To change the named parameters in the current URL I’ve created this small javascript function that will amend the URL: Continue reading

CakePHP: Components, redirect fail (On my part…)

I’ve been working on a CakePHP project lately and created a small component which was only needed in one of my controllers:

class CounterComponent extends Component {
  var $components = array(
    'Session'
  );
 
  function i() {
    if ($this->Session->check('Counter.i')) {
      $i = ($this->Session->read('Counter.i') + 1);
 
    } else {
      $i = 0;
    }
 
    $this->Session->write('Counter.i', $i);
 
    return $i;
  }
 
  function clear() {
    $this->Session->delete('Counter.i');
  }
}

Continue reading