vitalets / x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
http://vitalets.github.io/x-editable
MIT License
6.51k stars 1.73k forks source link

bootstrap-switch plugin for x-editable #1157

Open karmendra opened 4 years ago

karmendra commented 4 years ago

You can use this toggleswitch script with (image) or without (image) bootstrap-switch plugin:

.editable('show') is to make sure that the control is always shown If bootstrap_switch: true make sure you include bootstrap-switch library (tested with v3.3.4)

html:

<span>Verified:</span>
    <span id="verified"
      data-type="toggleswitch"
      data-value="{'true'}">
</span>

script:

$('#verified').editable({
    mode: 'inline',
    showbuttons: false,
    onblur: 'ignore',
    pk: 2,
    url: '/post.php',
    title: 'Verified',

    // toggleswitch specific options
    onchange: 'submit',
    bootstrap_switch: true,
    bootstrap_switch_options: {
        onText: 'YES',
        offText: 'NO',
        onColor: 'success',
        offColor: 'danger',
        size:'mini',
        inverse: true
    },
}).editable('show');
vitormicillo commented 4 years ago

and my suggestion for the field in the database is tinyint (1)