redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Checkbox Sorter

Open Abu-Taymiyyah opened this issue 13 years ago • 9 comments

Hello,

When one checked one checkbox of five checkbox, than after saved the other four unchecked checkbox are removed and the checked checkbox has no checked attribute. When one save against, than are the before saved options remove and all five checkbox displayed and the before saved options are not more saved for the checkbox sorter.

Here a picture of the normal:

unbenannt

Then after checked the first two and saved:

unbenaent

And here is the problem. One cannot set defaults and this two are not checked.

After i uptaded a other option, then looks like the first picture. The sort is reset and all are displayed again.

Can you make that one can set default and checked attribute, and that the not checked are not removed.

Abu-Taymiyyah avatar Oct 01 '13 13:10 Abu-Taymiyyah

Whew. You're right. That wasn't my code. Looks to be a bit of a mess. Have to fix it. On it.

dovy avatar Oct 01 '13 17:10 dovy

Oy, to get the checkboxes to save will require hidden elements added and removed by javascript. Oy.

dovy avatar Oct 01 '13 17:10 dovy

Can you tell me why/where the array are removed from the unchecked checkboxes? I have make this, but this is the last problem that the unchecked elements are removed and i search in the code but found yet nothing. thanks

Abu-Taymiyyah avatar Oct 01 '13 18:10 Abu-Taymiyyah

I'm trying to work around it. The issue is checkboxes if not checked don't post to the form. So I'm using javascript to append hidden elements when needed. It's a bit of a pain, heh.

dovy avatar Oct 01 '13 19:10 dovy

In smof framework they use something like that, so that the unchecked checkboxes also within a array. Checked with a 1 and unchecked with a 0.

$('#of_form :input[type=checkbox]').each(function() {
if (!this.checked) { serializedReturn += '&'+this.name+'=0'; } });

/** AJAX Save Options */
$('#of_save').live('click',function() {

    var nonce = $('#security').val();

    $('.ajax-loading-img').fadeIn();

    //get serialized data from all our option fields            
    var serializedReturn = $('#of_form :input[name][name!="security"][name!="of_reset"]').serialize();

            $('#of_form :input[type=checkbox]').each(function() {     
                 if (!this.checked) {
                    serializedReturn += '&'+this.name+'=0';
                 }
            });

    var data = {
        type: 'save',
        action: 'of_ajax_post_action',
        security: nonce,
        data: serializedReturn
    };

    $.post(ajaxurl, data, function(response) {
        var success = $('#of-popup-save');
        var fail = $('#of-popup-fail');
        var loading = $('.ajax-loading-img');
        loading.fadeOut();  

        if (response==1) {
            success.fadeIn();
        } else { 
            fail.fadeIn();
        }

        window.setTimeout(function(){
            success.fadeOut(); 
            fail.fadeOut();             
        }, 2000);
    });

return false; 

});   

Abu-Taymiyyah avatar Oct 01 '13 21:10 Abu-Taymiyyah

Resolved in a much simpler way in b75778a. Re-open if the problem persists.

dovy avatar Oct 01 '13 23:10 dovy

I tested and it works. Thanks. Also you shoud changed the css for the sortable checkbox, so that all drag icons are on the equal place.

unbenannt

i added a min-width: 100px; for the label.

Abu-Taymiyyah avatar Oct 02 '13 00:10 Abu-Taymiyyah

@Abu-Taymiyyah Made this change. I think you'll be satisfied with how it looks now.

dovy avatar Oct 15 '13 15:10 dovy

@Abu-Taymiyyah You may want to see this: https://github.com/ReduxFramework/redux-converter

dovy avatar Dec 21 '13 00:12 dovy