This doesn't use the Drupal behaviors or attach detach stuff, just plain old jquery straight up:
(function($) {
$().ready(function() {
alert('hello');
});
$('#submit').live('click', function(){
alert('ack!');
});
})(jQuery);
this works and says hello to you on page load, and upon clicking a submit button wrapped in a div with an id of #submit:
it says 'ack!' to you
Note you only need to wrap your javascript one time with the