0
I have a model where I have the attribute status
, this attribute is a int
that define values. In my form I have 2 buttons: gravar e publicar
and gravar
, each of these buttons would be a value for the status, in case the gravar e publicar
has value 1 and the gravar
value 0.
To define these values I am trying to use Jquery and change the model value when doing Submit, checking which button was clicked to change the value of status
, but I’m not getting it.
How can I do that ?
I’m trying like this.
html
<input type="submit" class="btn btn-success" value="Gravar e Publicar" id="gravarPublicar"/>
<input type="submit" class="btn btn-success" value="Gravar" id="gravar" />
jquery
$(document).ready(function () {
$('#addPropriedade').submit(function () {
//var dados = $(this).serialize();
var dados = new FormData($('#addPropriedade').get(0));
$('#gravarPublicar').click(function () {
dados.status = 1;
console.log(dados.status);
});
$('#gravar').click(function () {
dados.status = 0;
console.log(dados.status);
});
does not work, from the following error:
Uncaught ReferenceError: Invalid left-hand side in assignment
– FernandoPaiva