4

First of all, let me explain my page structure, so you can get the idea how is it working. I've got some number of quick-button blocks. They can be sorted by Jquery ui .sortable() method, but only after pressing settings button (which allows quick buttons to be sortable). Later, order of this buttons could be saved or could be canceled. So I need to look through 3 conditions which are fired up by click event. Problem is, on first time everything is ok, but on second time when I'm trying to press button settings - sortable() method is not working anymore.

You can see my JS below:

    $('#tune-hot-links').click(function () { //Click "settings" button  
            $(".sect-hot-links-inner").sortable();
            $(".sect-hot-links-inner").disableSelection();      
    });
    $('.button-editgroup button.button-save').click(function () {   //Click "save" button       
            $(".sect-hot-links-inner").sortable('disabled');
            $(".sect-hot-links-inner").enableSelection();               
    });
    $('.button-editgroup button.button-cancel').click(function () { //Click "cancel" button 
            $(".sect-hot-links-inner").sortable('cancel');
            $(".sect-hot-links-inner").sortable('disabled');
            $(".sect-hot-links-inner").enableSelection();   
    });

I've already tried to change .sortable() to .sortable('enable') at #tune-hot-links event. And it's not working.

1
  • can you post a fiddle Commented Apr 14, 2014 at 13:59

1 Answer 1

4

Well, I have no idea why, but seems that changing code like this:

$('#tune-hot-links').on( "click", function() {      
            $(".sect-hot-links-inner").sortable("enable");          
    });
    $('.button-editgroup button.button-save').on( "click", function() {         
            $(".sect-hot-links-inner").sortable("disable");
    });

    $('.button-editgroup button.button-cancel').on( "click", function() {   
            $(".sect-hot-links-inner").sortable('cancel');
            $(".sect-hot-links-inner").sortable("disable");
            $(".sect-hot-links-inner").enableSelection();   
    }); 

Resolved that issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.