Closed lucasjans closed 12 years ago
As an example, this article shows another system serializing the sorting data with a custom server side function: http://blog.greggbolinger.com/jqueryui-serializing-data-for-a-sortable-acco
Yes, let me get to you on this, there is a way
I think this is actually pretty easy, I could probably even do it now without any modifications to entityspaces code.
On a collection save event, first cycle through the accordion collection
$(this).find('h3').each(function() {
//somehow find the corresponding primary key for that item
//then save the record's Sort column value as the index
}
I will probably experiment with this soon and post something here.
So I thought I would have an easy time with this, but I am running into one challenge.
Here's the basic gist. I bound a hidden field to to the SortOrder column from the database. I figured if I changed the value for this field, it would update the view model. Wrong. Apparently, changing the $(element).val("tothis") doesn't trigger the knockout magic.
i = 1;
$(this).find('input[name=\'sortOrder\']').each(function () {
//this doesn't trigger KO's view model to change
$(this).val(i);
i++;
});
Is there a quick fix that I'm missing to get this working? Or should I start over and instead provide context to navigate through the view model arrays (I have multiple levels) and change the SortOrder data?
Found the easy solution http://stackoverflow.com/questions/7018885/knockout-js-bound-input-value-not-updated-when-i-use-jquery-valxyz
adding .change() works.
Ha, cool. I didn't even know about that .change() method, nice to know. Now that our latest maintenance release is out we should be doing some more work on entityspaces.js
One of my tables contains an int SortOrder column which is used to map the order that the items should be rendered in.
Do you know how to wire-up entityspaces.js to a sort order array? I am using jQuery UI Accordion, which does support sorting.