Have a list of editable items relative to a given user that I would like to be non-GET initiated; i.e. when clicking the edit button for a given entry, I would like that to initiate a POST to the target edit form screen.
How can I achieve this short of wrapping every edit button in the list in <form>...</form>?
Currently I have a jQuery location.href kicking the user to target edit screen; however, with GET the user could enter any id they like by simply entering a URI of their choosing.
$('.game-edit').click ->
location.href = '/admin/linescore/edit/' + getID($(this))
Can I click event POST a la location.href?
Ideas appreciated, thanks
$('a').click(function(){
$('#formID').action = $(this).href
$('#formID').submit();
})
Is there any reason you can't have jQuery do the POST for you? Given:
<a class="edit" href="...">Click Me</a>
...then:
$('a.edit').click(function(){
var postUrl = $(this).attr('href'); // href attribute of clicked link
$.post(.....);
});
EDIT - Updated for clarity's sake
Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With