On Fri, Oct 2, 2009 at 3:11 PM, Gremlyn1 <[email protected]> wrote: > > OK, so I tried out your code, adding the missing ',' at the end of the > placeholder line, and it is almost working. I am posting the variable > from the hidden input and calling the results from a PHP print_r for > now, just to see whats going on. It isn't separating the <li id="*"> > into individual key->value pairs, I'm getting something like this: > Array ( [0] => 16,10,2,14,9,15,12,3,1,13,11,8 [1] => [2] => [3] => [4] > => [5] => [6] => [7] => [8] => [9] => [10] => [11] => > 8,16,10,12,2,1,3,13,9,11,14,15 ) > > There is always a string in the [0] spot, and where the second string > ends up depends on how much sorting I do. I only seem to get two > strings output. I thought maybe having the name="faq_order[]" set to > an array was messing it up, but if I take that, I get nothing printing > out at all. If I can only get a string like that out, I don't mind, I > can always explode it with PHP and work with it, but I'll need to be > able to know where the string is and which is right somehow... > > Yes, toArray returns a javascript array, when you set it on the hidden input its converted to a string which apparently is not in the correct format for php. You will need to loop through the array and create a proper string which php can understand.
> Oh, and one weird (maybe?) thing, if i leave console.log line in, the > script only works with Firebug active. > > Yes, firebug adds the console object when it as active. If its not active then console is undefined and trying to call a method (.log) on an undefined item is an error. Some other browsers also implement the console object. > On Oct 2, 11:42 am, Gremlyn1 <[email protected]> wrote: > > Thanks, I think the stop event is what I'm looking for. I do have > > firebug, but alas I'm so new to JS that I can't properly utilise it's > > helpfulness. Does the console.log line specifically tie in to > > firebug? > > > > On Oct 2, 11:18 am, Nate Laws <[email protected]> wrote: > > > > > Your initializing syntax is wrong. The function that you pass doesn't > > > actually do anything. You probably want: > > > $j("#faq_sort").sortable({ > > > axis: 'y', > > > handle: 'img', > > > placeholder: 'ui-state-highlight' > > > stop: function(event, ui) { > > > var faq_ord = $j("#faq_sort").sortable('toArray'); > > > console.log(faq_ord); // debug statements are > really > > > helpful > > > document.getElementById('faq_order').value=faq_ord; > > > } > > > }); > > > > > I would recommend checking out the different sortable events to see > which > > > works best for you. > > > > > Also, you need to get firebug for firefox and learn how to use its > console. > > > > > On Thu, Oct 1, 2009 at 7:06 PM, Gremlyn1 <[email protected]> wrote: > > > > > > First off, I'm VERY new to javascript/jquery so I definitely doing > > > > something wrong, I just need a little help figuring out what it is. I > > > > have an unordered list of FAQs that I need to be able to drag/drop > > > > into the order I want and then submit that to the database. I'm not > > > > using AJAX at the moment, one programming step at a time ;) The > > > > sorting function works just fine, I can move them all I want, but I > > > > need to get them to set toArray. I am then passing that via a hidden > > > > input HTML element with a form button. My form is generated by > various > > > > PHP functions and database calls, but I dumbed it down to make it > > > > readable. The form works right now as I am using drop down boxes to > > > > choose the number in the order, so it isn't a separate HTML/PHP > issue. > > > > Here is what I have so far: (I have a bunch of other jquery functions > > > > in the '.ready(function() {' as well, but I cut them out, those all > > > > work) > > > > > > <script type="text/javascript"> > > > > var $j = jQuery.noConflict(); > > > > > > $j(document).ready(function() { > > > > $j("#faq_sort").sortable({ > > > > axis: 'y', > > > > handle: 'img', > > > > placeholder: 'ui-state-highlight' > > > > }, function() { > > > > var faq_ord = $j('#faq_sort').sortable('toArray'); > > > > document.getElementById('faq_order').value=faq_ord; > > > > }); > > > > )}; > > > > </script> > > > > > > <form method="post" action="mysite.php"> > > > > <input type="submit" name="submit" id="reorder" value="REORDER" /> > > > > <input type="hidden" id="faq_order" name="faq_order[]" value="" /> > > > > <ul id="faq_sort"> > > > > <li id="faq_1"><img src="handle.png">FAQ 1</li> > > > > <li id="faq_2"><img src="handle.png">FAQ 2</li> > > > > <li id="faq_3"><img src="handle.png">FAQ 3</li> > > > > </ul> > > > > </form> > > > > > > Any help getting this working would be greatly appreciated! Thanks! > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~---
