Joshua
Joshua

Reputation: 791

Twitter Bootstrap Modals and CRUD

So, I'm specifically developing my application in Laravel, but I think this question is a bit more general to any web application as it's really around the usage of bootstrap and modal pages.

I'm interested in finding out how others have created CRUD functionality using the packaged bootstrap modal.

The modal seems a natural fit for all types of forms. The issue really comes around the setup. I was trying to create a contact CRUD for my application.

For example, an Account may have multiple contacts, so while view the Account page I would like the user to be able create or update a contact using the same form presented via a modal.

Using only the bootstrap package you can load a modal's body with remote data, but only once. So I open contact 1 for editing, close the modal, and try to open contact 2 the only info I get is for contact 1 as it won't do a second remote load.

This can be solved easily enough with the great info in this post Twitter bootstrap modal loads wrong remote data

While this solution works well, it seems like I'm breaking the framework and feels like I'm using the modal for something it wasn't intended for. Perhaps the bootstrap modal isn't the right ui element for a CRUD. So, how do others approach this?

Upvotes: 1

Views: 5638

Answers (2)

msurguy
msurguy

Reputation: 524

I have done this. The way to go about that is to use jQuery AJAX calls and test for Ajax requests in Laravel application.

Here is a nice tutorial on working with Ajax in Laravel: http://codehappy.daylerees.com/ajax-content

To validate your forms I recommend Parsley.js, works awesome with Bootstrap : http://parsleyjs.org/

Also there is a great plugin written specifically for Bootstrap ajax calls, check out about how to integrate it in my forum post here: http://forums.laravel.io/viewtopic.php?pid=27900

Upvotes: 2

isherwood
isherwood

Reputation: 61124

My company used Bootstrap modals to do fairly complex form data interactions with good success. I see no reason why you can't use ajax or whatever, along with modals, to make a more seamless user experience. A modal is nothing more than a div on a floating page layer, after all.

Upvotes: 1

Related Questions