Skip to content

Using custom properties

jmarnold edited this page Jul 7, 2012 · 1 revision

Overview

It can be handy to pass custom information along to your policies (metadata, jquery objects, etc.). Any options passed along are made available via the options property on the continuation.

There are two ways to do this:

$.ajax

If you are making a simple $.ajax post, you can pass an options object:

$.ajax({ options: { customProperty: '1234' } })

$.correlatedSubmit

If you are using the correlatedSubmit method, any properties you specify will be used as options:

$('#myForm').({ customProperty: '1234' })

Consuming the options

The following is an example of a policy consuming the options:

{ matches: function(continuation) { return typeof(continuation.options.customProperty) != 'undefined'; }, execute: function(continuation) { alert(continuation.options.customProperty); } }

Clone this wiki locally