I faced same problem. First you need go through the events (i.e which event is happening first).
For example:
The First event is generating select box with options.
The Second event is selecting default option using any function such as val() etc.
You should ensure that the Second event should happen after the First event.
To achieve this take two functions lets say generateSelectbox() (for genrating select box) and selectDefaultOption()
You need to ensure that selectDefaultOption() should be called only after the execution of generateSelectbox()