No problem,

$(document).ready(function(){
});

and

$(function(){
});

are the same - both will run whatever you have in them when the DOM is ready - the second is just a kind of shorthand for the (much easier to read) first. Docs:

.ready()
http://api.jquery.com/ready/

$(callback)
http://api.jquery.com/jQuery/#jQuery3

When you have multiple instances of these constructs in your scripts, the code within them will run in the order in which they are defined, so in your example, what was happening was the first $("#elements").sortable(); (defined within the $(function(){}); block) was creating the sortable list - the second call (within $(document).ready) was ignored.

Hope this helps,

Peter


on 23/02/2010 10:32 rafald said::
Hi Peter,
Indeed! It works ;-) THANKS!
It was enough to remove line with >> $("#elements").sortable(); <<

So, what is the right place to put:
$("#elements").sortable();
?

in my example:
the first place was outside "$(document).ready(function()"
the second place (where I added event) was inside "$
(document).ready(function()"

What are the rules  here and what will be difference if I put inside
or outside ?
Could you please explain this to me ?

regards
Rafal

Reply via email to