Extend JQuery with function
Hi,
A newbie question, I'm afraid...
I have extended sortables with my own function which works fine as an
onlcick event.
However, I need the function to be fired off when a box has been moved
(ie the DOM has finished being updated) because I find the position of
the boxes and write to a db. I tried the mouseup event but it is too
early as the DOM isn't finished.
The fact it is a new function is irrelevant as I could have wanted to
use 'serialise' to grab the positions into a cookie or whatever. But
where would this call go?
I currently have:
<script type="text/javascript">
jQuery.fn.serialize_mis = function()
{
var divs = document.getElementsByTagName("div");
var fullid = ' ';
var shortid = ' ';
var str = ' ';
var url = boxes_update.php?staff_code=x';
var i;
var y = 0;
for (i=0;i<divs.length;i++)
{
fullid = divs[i].getAttribute("id");
shortid = fullid.substring(0,3);
if (shortid == 'box')
{
str = str.concat(fullid,'-');
}
}
url = url.concat(staff_code,'&ord=',str);
//alert(url);
ajaxgo(url); // go off and update the database
};
$(window).bind("load",function(){
$("#container").sortable({
revert: true,
scroll: true,
placeholder: 'hover', //the class te placeholder should have
placeholderElement: '> div'
});