Fixed query.ready function and added query.trigger.