0

Hello. So here's the stitch. I was asked to modify some existing code to only prompt the user to save changes when a change was actually made and not every time the new page button was pressed - which was what it was currently doing.

I've ran into a bit of a snag with one part. It uses this plugin http://mjsarfatti.com/sandbox/nestedSortable/ to allow the user to sort pages that are created.

It also runs a separate javascript function to hide and delete pages. So I added a global var that gets changed from 0 to 1 when either of these two functions are called and changed it so it only prompts if the var == 1. So this part works fine.

The trouble is with the sorting function. Is there a way for me to monitor when it's triggered - without having to mess around with the plugin code? Something like:

            if(nestedSortable is triggered){
                changed = 1;
                }
2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by dyingatmidnight
0

It appears to trigger a sort event, but I am not sure where you can trap it yet (I have never used this plugin before).

0

so I had an idea, not sure if its something that can be done - the internet has been less than helpful when I search. The draggable elements are in this format .sortable li div, so I was thinking if it were possible to bind the drag event for these divs and have var change accordingly.

            $('.sortable li div').bind('click', function(){
                alert( "this is a drag");
                changed = 1;
            });

This is the test code I've been playing with, just not sure if 'drag' is something that can be captured - since it didn't seem to work when I tried. The only problem with binding the click function is that there a couple icons on the div that shouldn't trigger a change. I thought about doing this:

            $('.sortable li div').bind('click', function(){
                alert( "this is a drag");
                changed = 1;
            });
            $('.sortable li div .none').bind('click', function(){
                alert( "this is none");
                changed = 0;
            });

but the second event is fired first followed by the other so changed is always equal to one. Don't mind the testing alerts :P

Edited by dyingatmidnight

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.