Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app" class="container mb-4">
	<h1 class="font-weight-light text-center mb-3 mt-2">
		Library Borrowing System
	</h1>
	<table class="table table-striped">
		<thead>
			<tr>
				<th scope="col">No.</th>
				<th scope="col">Title</th>
				<th scope="col">Author</th>
				<th scope="col">Description</th>
				<th scope="col">Actions</th>
			</tr>
		</thead>
		<tbody>
			<tr v-for="(book, index) in books">
				<th scope="row">{{ index + 1 }}</th>
				<td>{{ book.title }}</td>
				<td>{{ book.author }}</td>
				<td>{{ book.description }}</td>
				<td>
					<button :disabled="book.availableNumber < 2 || isBorrowed(book)" 
							@click="borrowBook(book)" 
							type="button" class="btn btn-primary btn-sm">
						Borrow{{ isBorrowed(book) ? 'ed' : '' }}
					</button>
				</td>
			</tr>
		</tbody>
	</table>
</div>
              
            
!

CSS

              
                button:not([disabled]) {
	cursor: pointer;
}
              
            
!

JS

              
                $(document).ready(() => {
	
	new Vue({
		el: '#app',
		data: {
			books: [],
			borrowedBooks: []
		},
		created() {
			this.books = getData()		
		},
		methods: {
			borrowBook(book) {
				this.borrowedBooks.push(book.id)
				toastr.success(book.id, 'Borrowed Book!')
			},
			isBorrowed(book) {
				return this.borrowedBooks.find(id => book.id === id) !== undefined
			}
		},
		watch: {
			books() {
				if (!$.fn.DataTable.isDataTable('table'))
					$('table').DataTable()
			}
		}
	})
	
})

getData = () => [
	{
		"id": "9781593275846",
		"title": "Eloquent JavaScript, Second Edition",
		"author": "Marijn Haverbeke",
		"description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.",
		"availableNumber": 2
	},
	{
		"id": "9781449331818",
		"title": "Learning JavaScript Design Patterns",
		"author": "Addy Osmani",
		"description": "With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.",
		"availableNumber": 3
	},
	{
		"id": "9781449365035",
		"title": "Speaking JavaScript",
		"author": "Axel Rauschmayer",
		"description": "Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.",
		"availableNumber": 1
	},
	{
		"id": "9781491950296",
		"title": "Programming JavaScript Applications",
		"author": "Eric Elliott",
		"description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.",
		"availableNumber": 4
	},
	{
		"id": "9781593277574",
		"title": "Understanding ECMAScript 6",
		"author": "Nicholas C. Zakas",
		"description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.",
		"availableNumber": 4
	},
	{
		"id": "9781491904244",
		"title": "You Don't Know JS",
		"author": "Kyle Simpson",
		"description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language.",
		"availableNumber": 2
	},
	{
		"id": "9781449325862",
		"title": "Git Pocket Guide",
		"author": "Richard E. Silverman",
		"description": "This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.",
		"availableNumber": 1
	},
	{
		"id": "9781449337711",
		"title": "Designing Evolvable Web APIs with ASP.NET",
		"author": "Glenn Block, et al.",
		"description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.",
		"availableNumber": 3
	},
	{
		"id": "9781593275846",
		"title": "Eloquent JavaScript, Second Edition",
		"author": "Marijn Haverbeke",
		"description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.",
		"availableNumber": 2
	},
	{
		"id": "9781449331818",
		"title": "Learning JavaScript Design Patterns",
		"author": "Addy Osmani",
		"description": "With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.",
		"availableNumber": 3
	},
	{
		"id": "9781449365035",
		"title": "Speaking JavaScript",
		"author": "Axel Rauschmayer",
		"description": "Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.",
		"availableNumber": 1
	},
	{
		"id": "9781491950296",
		"title": "Programming JavaScript Applications",
		"author": "Eric Elliott",
		"description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.",
		"availableNumber": 4
	},
	{
		"id": "9781593277574",
		"title": "Understanding ECMAScript 6",
		"author": "Nicholas C. Zakas",
		"description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.",
		"availableNumber": 4
	},
	{
		"id": "9781491904244",
		"title": "You Don't Know JS",
		"author": "Kyle Simpson",
		"description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language.",
		"availableNumber": 2
	},
	{
		"id": "9781449325862",
		"title": "Git Pocket Guide",
		"author": "Richard E. Silverman",
		"description": "This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.",
		"availableNumber": 1
	},
	{
		"id": "9781449337711",
		"title": "Designing Evolvable Web APIs with ASP.NET",
		"author": "Glenn Block, et al.",
		"description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.",
		"availableNumber": 3
	}
]
              
            
!
999px

Console