2
I am not able to add a data attribute(data-state) as I did with the other tag(value, type, name, etc) as shown in the following image:
$(".clicka").on("click", function () {
$('#calendartable .tdfull').each(function (k) {
if ($(this).data("id")) {
$('<input/>').attr({
type: 'hidden',
name: 'disponibilidade[' + k + ']',
value: $(this).data("id"),
state: $(this).data("pending"),
}).appendTo('form');
}
$('<input/>').attr({
type: 'hidden',
name: 'disponibilidade[' + k + '].titulo',
value: $(this).data("start") + ' - ' + $(this).data("end"),
state: $(this).data("pending"),
}).appendTo('form');
$('<input/>').attr({
type: 'hidden',
name: 'disponibilidade[' + k + '].inicio',
value: $(this).data("start"),
state: $(this).data("pending"),
}).appendTo('form');
$('<input/>').attr({
type: 'hidden',
name: 'disponibilidade[' + k + '].fim',
value: $(this).data("end"),
state: $(this).data("pending"),
}).appendTo('form');
});
He doesn’t recognize the state, and I think he’s doing something wrong. I wanted to put the state in "pending". Is there any event that does? I searched for deferred but did not get the idea. Thank you.
Look at how I did input. I had already seen this documentation, however I was trying to put in my input. It is possible to do my $(this). data("state", "pending") ?
– n1c0t0p
do so, where this state places 'data-state'
– Diego Vieira
that way does not, gives error because of the "-". I tried @Sergio’s second hypothesis and it is not working either. HTML shows me this: <input type="Hidden" name="availability[3]. end" value="2015-02-27 15:00"> E must appear this: <input type="Hidden" name="availability[3]. end" value="2015-02-27 15:00" data-state="pending">
– n1c0t0p