0

I'm trying to port one of my desktop apps to a web app. It's a translation tool. Some views will have multiple forms and if possible will have a couple buttons in each form for the same resource. I don't know if the latter is possible?

Example


form for action post

Field 1 – source text

Field 2 – target text

Submit for action post | Submit for action search


The post action saves the translation pair to DB and the search action searches the DB and returns all translation pairs based on a condition (lets say if the source contains a certain word).

Can this be done in some way as described or would I have to use separate form for the search action?

Regards,

seba

4

1 回答 1

0

You can do that by overwriting the form action before submitting the form:

$('[data-triggers*="change-action-and-submit"]').click(function() {
  $(event.target).parents('form').attr('action', $(event.target).data('action'));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form action="/">
  <input type="name" />
  
  
  <button type="submit">Save</button>
  <button type="submit" data-triggers="change-action-and-submit" data-action="search">Search</button>
</form>

于 2015-06-12T11:47:58.207 回答