Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Jeditable use the Bootstrap button classes for Ok/Cancel?

I know that I can style the "Ok" and "Cancel" buttons created by Jeditable with a css file like this:

form.editable > button {
color : #F00
}

I want Jeditable to use the existing Bootstrap classes btn btn-danger and btn btn-success.

I know I can just copy and paste the CSS from bootstrap into my custom css file but this seems disgusting.

What is the proper way to do this? I have googled around without much success and read the jeditable docs, but the solution is not obvious to me.

like image 248
John Shedletsky Avatar asked Feb 11 '23 18:02

John Shedletsky


2 Answers

I just got interested in this and I found out that it is as simple as this :)

$('.edit_area').editable('http://www.example.com/save.php', {
     type: 'textarea',
     cancel: '<button class="btn btn-danger" type="cancel" >Cancel</button>',
     submit: '<button class="btn btn-success" type="submit" >Ok</button>'
});
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//rawgit.com/tuupola/jquery_jeditable/master/jquery.jeditable.js"></script>

<div class="edit_area">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae officiis reprehenderit tempora rerum quaerat sed totam recusandae sint doloremque perspiciatis omnis illum facilis odio perferendis quibusdam sequi ab consectetur repudiandae.</div>
like image 148
Bojan Petkovski Avatar answered Feb 14 '23 23:02

Bojan Petkovski


  1. Visit the Bootstrap CSS customize page: http://getbootstrap.com/customize/
  2. Click 'Toggle All' and select only 'Buttons'
  3. Click Compile and Download
  4. Open the zip file and load the bootstrap-theme.css file into your app
  5. Add the btn classes your buttons: <button class="button btn btn-success" type="submit" >Ok</button>

This will give you just the Bootstrap you need (not the entire CSS library) and allow you to style your buttons as Bootstrap buttons.

like image 45
Marty Cortez Avatar answered Feb 14 '23 23:02

Marty Cortez