DEV Community

Chamara Abeysekara
Chamara Abeysekara

Posted on

2

LaraCRUDJS

So for the post, I thought I write about something that I developed a few months back. This a JavaScript library I have written to manage CRUD functions.

You can find it no GitHub https://github.com/chamra/laraCRUDJS

Once you downloaded the zip you can place laraCRUD.js file in your assets folder and reference it in your app.balde.php file.

<script src="{{ assets('js/laraCRUD.js') }}"></script>

after that, it's all a matter of time you create an object from CRUD class

const crud = new CRUD()

you can override all defaults from the constuctor. default is,

{
//form element id
this.form = "formData";
//modal id that include the form
this.modal = "#formModal";
//form submit buttom id
this.submitButton = "#btnSubmit";
//propertie for datatables
this.datatables = "";
//resource url
this.url = "";
//unable page refresh afer a form a submit
this.refreshPage = false;
//current status of the form to be update or create
this.update = false;
//csrf token
this.token = document.head.querySelector('meta[name="csrf-token"]');
//selected items auto increment id
this.id = 0;
}

calling the method initCRUDFunctions() on crud will in initiate basic crud function you need for the instance.

crud.initCRUDFunctions()

for example - https://github.com/chamra/laraCRUDJS/blob/master/example/main.js

Help is always welcome, so fork me ✌!

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay