Skip to content
This repository was archived by the owner on Jul 29, 2022. It is now read-only.

Checkbox added#52

Closed
ghost wants to merge 1 commit intomasterfrom
unknown repository
Closed

Checkbox added#52
ghost wants to merge 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Nov 9, 2011

I fixed this checkbox here svn.appelsiini.net/svn/javascript/trunk/jquery_jeditable_contributed/jquery.jeditable.checkbox.js

@tuupola
Copy link
Collaborator

tuupola commented Nov 9, 2011

Thank. What were the bugs that you fixed?

@ghost
Copy link
Author

ghost commented Nov 9, 2011

oh, I meant that bugs with the control, it was incorrectly put state.

@tuupola
Copy link
Collaborator

tuupola commented Nov 9, 2011

Yes I understood :) But what kind of bugs did jquery.jeditable.checkbox.js have?

@ghost
Copy link
Author

ghost commented Nov 9, 2011

Bugs with correct setting checked attribute.

@ghost
Copy link
Author

ghost commented Nov 11, 2011

ok, i'll close the request

@ghost ghost closed this Nov 11, 2011
@tuupola tuupola reopened this Nov 11, 2011
@tuupola
Copy link
Collaborator

tuupola commented Nov 11, 2011

Sorry I just have not had time to do this yet. Will check it during the weekend. Reopened.

@pushpinderbagga
Copy link

I don't know if this will be useful - but I needed this at urgent so I made a dirty work around. I just wanted to set a DB field 1 OR 0 with Check or Uncheck of the Checkbox. So here is what I did.

First, I displayed it like this

if($id->is_top =='1'){
echo "<td class='edit_top' id='".$id->id."'>Yes</td>";
}
else{
echo "<td class='edit_top' id='".$id->id."'>No</td>";
}

Then - the checkbox plugin I tweaked is as below.

$.editable.addInputType("checkbox", {
    element : function(settings, original) {
        var input = $('<input type="checkbox" >');
        $(this).append(input);      
        return(input);
    },
    content : function(string, settings, original) {        
        var checked = string == "Yes" ? 1 : 0;
        var input = $(':input:first', this);
        var value = "";

        if(checked == 1){
            $(input).attr("checked", checked);
            $(input).checked = true;
            value = '1';
        }
        else{
            value = '0';
            $(input).removeAttr('checked');
        }

        $(input).val(value);        
    },
    submit: function (settings, original) {
        var value = "";
        var input = $(':input:first', this);
        if(input.attr('checked')){
            value = '1';
        }
        else{
            value = '0';
        }
        $("input", this).val(value);        
    }
});

Hope this helps whosoever is in need.

Cheers!

@NicolasCARPi
Copy link
Owner

Hello,

The checkbox has been added to the code. Thanks for your contribution :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants