Reputation: 23159
Can someone explain the jQuery equivalent of Form.event.findElement to me?
$('.ad-publish-button').bind('click', function(e) { // jquery
// section of prototype I need to convert to jquery
if ( e.findElement('.ad').down('form').down('#location').value != '' ) {
e.findElement('.ad').down('form').request();
}
});
Upvotes: 0
Views: 592
Reputation: 117334
give it a try
$('.ad-publish-button').bind('click', function(e) {
var _form=$('form',$(e.target).closest('.ad')[0]).first();
if ($('#location',_form).val() != '') {
$.ajax(_form.prop('action'), {type:_form.prop('method'),data:_form.serialize()});
}
});
e.target
is the clicked element$(e.target).closest('.ad')[0]
is the closest ancestor with className '.ad'$.ajax()
will send a request(using the form- properties action+method and the serialized elements)Upvotes: 1