i have created a form in salesforce lightning using form tag and one button there is inputtype="submit", value="submit", i dont want to reload the page when submit clicked. please help me out.
<aura:component>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<form action=" url" method="post" I'd="form"/>
<Inputtype="submit",value="submit" >
</aura:component>
doInit: function(component, event, helper)
{
$( "form" ).submit(function( event ) {
event.preventDefault();
return false;
});
}
it is not working if i used in doInit.
Update:
submitForm : function () {
$( "form" ).submit(function( event ) {
event.preventDefault();
return false;
});
}
this submitFrom() function i have called in onclick method for button.
<input type="submit" name="submit" onsubmit="submitForm()"/>
but it is not working. page is still loading.
submit
type button triggers browser's HTML5 form validation. So it's nice to leverage that, do the submission through AJAX but then prevent the actual page reload - very trivial in plain HTML/JS but apparently complicated in Lighting.