the problem here is that I have a form that gets his values form an angular function. I have one button that change the values for the inputs tags and I have a submit button that send those values. So when I press that last button It work fine. But I want that the first button not only changes the form's values also click the submit button. So here is the function that changes the form's values.
todoList.remove = function(aborrar) {
if (aborrar.id != undefined || aborrar.id != null) {
todoList.elaborrar = aborrar.id;
console.log("si tiene id y es "+aborrar.id);
todoList.elnoquerido = '/api/users/remove_tags/<%=user.id%>';
console.log(todoList.elnoquerido);
$('#elimina').trigger("click"); //THIS IS THE PROBLEM
};
angular.forEach(todoList.todos, function(todo,i) {
if (aborrar.title==todo.title) {
todoList.todos.splice(i, 1);
};
});
};
and the html
<form name='myform2' method="POST" class="" novalidate action="{{todoList.elnoquerido}}" >
<input type="hidden" name="_csrf" value="<%= _csrf %>">
<input name="aborrars" type="hidden" value="{{todoList.elaborrar}}">
<input id="elimina" class="btn btn-medium btn-primary elimina" type="submit" value="Eliminar">
</form>
I think this may is happen because some async thing? I've also try with this...
document.getElementById("elimina").click();
and this
$('#elimina').click();