Since you didn't specify any container for the endpoints, by default it will take the parent DIV. While connecting endpoints having parent as different DIV's yields in weird connections. You need to specify a common container for all endpoints as:
jsPlumb.Defaults.Container=$("#container");