While developing a subscription module i required the need to trigger an onchange event.

I had a <select> which displayed all the products and when the selected option value changed it would perform an ajax request and load the products options to be displayed below the product.

This worked like a charm however I needed to ensure that when I was viewing a subscription the form was preloaded with the chosen product option value and also the product options. So i needed to figure check to see if there was product and if so trigger the change. This can be done like so:

$('#subscription_type_product_id').change(function(){
        //Code here for the ajax request to load product options...
});

Above was the original .change() function. Now to trigger the above we simply call:

$('#subscription_type_product_id').trigger('change');

Please note that the trigger needed to be placed after the original .change() declaration.