views:

41

answers:

1

I have a select list which has a function with a jQuery .post bound on the change() event.

<select id="location">
<option value="1"></option>
<option value="2"></option>
</select>

$('#location').change(location_change);

function location_change(){
    var url = '';
    $.post(url, callback);
}

What I would like to happen is other controls on the page can bind to the $.post callback function like it was an event, so after the location is changed the data is posted back to the server and once the post returns successfully, the subscriber events are fired.

+2  A: 

You can do this with custom events. Make the post callback call a trigger('my_posted_event') and register any event handlers for that custom event using bind('my_posted_event').

Max Shawabkeh
Most excellent. Dang, I love jquery
Charlie Brown