So a few questions.
I see you have JS code to get the order out from the list. Have you
confirmed it does so correctly? Ie, if you console.dir($("##wrapper
form").serialize()) do you see the proper data there?
If so - the next thing to do is look at your CFC code and see how it
gets it. When jQuery does a serialize on form fields, it can create a
structure of data that doesn't always mesh well with CF. SO for
example, and I'm going by memory here so take this with a grain of
salt, it may pass fields like so:
name[1]=ray&name[2]=jay
While that works fine in PHP, it doesn't work well in CF. Normally I
write my own code to serialize the form data. Obviously though if you
take your CFM that you are calling and <cfdump> the form scope to a
file, you can see exactly what CF "got" when you posted your crap.
Make sense?
On Thu, Jun 21, 2012 at 10:23 AM, Teed Younger <[email protected]> wrote:
>
> Sorry if this is the wrong place, but given than Im using CFC's to create
> database gets and sets, and have no luck in any js/jquery forums because most
> of them dont understand CF, I thought I'd post here.
>
> I have a sortable/drag and drop list(s). Meaning I can sort both list orders
> and drag from the first list to the other. All that works pretty much. My
> issue is of course I need to save the sort order with json data and update
> the database by way of my setMediaEditAJAX method in my cfc. As I have it
> now, I can sort and click the button and get a success alert, but a dump of
> my data shows the order was not saved.
>
> Maybe my method is incorrect, or maybe the js is incorrect. I'm really new to
> js, so my bet would be the js. Its mostly code I found and copied, but here
> is the code. I would appreciate any help given.
>
> <div class="left">
> <div id="songList">
> <fieldset class="one">
> <h3>All Songs</h3>
> <div id="instructions">Drag and drop or re-order Tracks</div>
> <div id="songList">
> <ul id="sortable1" class='droptrue'>
> <cfloop from="1" to="#variables.songData.songListCnt#" index="i">
> <li class="ui-state-default"
> id="article_1">#variables.songData.songList[i]# <input type="hidden"
> name="prodID" value="#variables.songData.songList[i]#" /></li>
> </cfloop>
> </ul>
> </div>
> </fieldset>
> </div>
> </div>
> </form>
> <form name="trackListEdit" action="index.cfm?action=younger.albumsEdit"
> method="post">
> <div class="right">
> <div id="trackList">
> <fieldset class="two">
> <h3>Tracks on - #variables.songData.albumName#</h3>
> <div id="instructions">Drag and drop songs to upload and re-order Album
> Tracks</div>
> <ul id="sortable2" class='droptrue'>
> <cfloop from="1" to="#variables.songData.trackListCnt#" index="i">
> <li>#variables.songData.trackList[i]#<input type="hidden"
> name="prodID" value="#variables.songData.trackList[i]#" /></li>
> </cfloop>
> </ul>
> </fieldset>
> </div>
> <a id="save-button" class="button secondary" href="##">Edit</a>
> </div>
>
> <script language="JavaScript" type="text/javascript">
> $(function() {
> $("ul.droptrue").sortable({
> connectWith: 'ul',
> opacity: 0.6,
> update : updatePostOrder
> });
>
> $("##sortable1, ##sortable2").disableSelection();
> $("##sortable1,
> ##sortable2").css('minHeight',$("##sortable1").height()+"px");
> updatePostOrder();
> });
>
> function updatePostOrder() {
> var arr = [];
> $("##sortable2 li").each(function(){
> arr.push($(this).attr('id'));
> });
> $('##postOrder').val(arr.join(','));
> }
> $('##save-button').click(function() {
> var ids = [];
> $('##sortable2 > li.stories').each(function(el) {
> ids.push($(this).attr('id'));
> });
>
> var id = $('##brsel option:selected').attr('value');
> // var url = "index.cfm?action=younger.trackListEdit"+id;
> $.ajax({
> type: "POST",
> url: "index.cfm?action=younger.trackListEdit"+id,
> dataType: "json",
> data: $("##wrapper form").serialize(),
> success: function(){
> alert("Changes been succesfully saved");
> }});
> });
> </script>
> Thanks in advance.
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351638
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm