I have this working however I cant get it to work within my existing code.
What I need to happen is: http://jsfiddle.net/uJcB7/176/
So when I add features from the checkbox into the div it puts them in a list. I have each function working but can not figure out how to combine the two.
So that when you add in the features from the checkbox into the div, it adds the string of features as a list which I can the drag around.
Cheers
I guess the easiest way to answer is with a demonstration?
jsFiddle demo
Hopefully this is what you’re after, I’ll break down the code for you.
First I merged your document ready function calls, and collapsed any jQuery statements that were using the same selectors at the appropriate time. This resulted in the initialisation code, which is:
Then I collapsed the original
allValsarray and replaced it with jQuery’smapfunction. Themapfunction is essentially theeachfunction, with the added bonus of the result being an array of any elements that are returned. Within themapfunction we’re simply returning the.valueof all selected HTML inputs 1-by-1. I’m thenjoin‘ing them with a slightly nicer,join. This gives us:In addition to this, as previously mentioned, the
mapfunction acts similar to theeachfunction. This allows us to construct a new sortable list at the same time as selecting the text to display in thediv. First we need to clear out the old sortable, then we’ll add the selected items, and finally we’ll construct a new sortable. This gives us the following: