1

My View Edit have some steps and I would like to Save step by step, I think I need a JQuery for it, don't know how.

Steps:

<ul class="nav nav-tabs">                            
    <li class="active">
        <a href="#cliente" data-toggle="tab">Cliente</a>
    </li>
    <li>
        <a href="#peca" data-toggle="tab">Peças</a>
    </li>
    <li>
        <a href="#validacao" data-toggle="tab">Validação</a>
    </li>
    <li>
        <a href="#instalacao" data-toggle="tab">Instalação</a>
    </li>
    <li>
        <a href="#colaboradores" data-toggle="tab">Colaboradores</a>
    </li>
</ul>

Submit Button:

<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <input type="hidden" value="Save" id="salvar" class="btn btn-default" />
    </div>
</div>

Post Controller:

if (ModelState.IsValid)
{
    db.Entry(manutencao).State = EntityState.Modified;
    db.SaveChanges();
    return RedirectToAction("Index");

}
4
  • If you want to save step by step, you should use ajax to save, after each tab. Commented Jun 8, 2016 at 18:39
  • It's hard to tell from your question, but it sounds like you want to do incremental saves without reloading the page. You need to look at AJAX form submitting to do this. Commented Jun 8, 2016 at 18:40
  • Or, use 5 different pages posting to the server Commented Jun 8, 2016 at 18:46
  • Try to user knokout Commented Jun 8, 2016 at 19:53

1 Answer 1

2

As the commenters mentioned, to prevent a page refresh, you need to do an ajax request. jQuery is certainly a good option, but you could use native javascript as well.

Something like this:

$.ajax({
    url: 'controller action url',
    type: 'POST',
    data: {
       whatever
    },
    success: function (results) {
         do stuff
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.