Back to the Learning!

Laracasts is packed full with over 1,000 lessons just like this one.

Sign up to get full access or log in to your account and sit back.

Published On Jan. 21st 2016

Learning Vue 1.0: Step By Step: Custom Directives and Asynchronous Forms

Episode 16 Run Time 21:29

Download

Often, you'll find yourself in the position of wanting a form to submit asynchronously. Or, in other words, rather than performing a full post back to the server and refreshing the page, we'd rather opt for a simple AJAX request behind the scenes. Well at this point in your learning, you already know one way to hijack a form's submission, but what if we could instead create a reusable Vue directive to simplify things? What if we could simply add v-ajax to a form tag, and have it automatically switch to using AJAX for its submission?

View the source for this lesson on GitHub.