I was thinking about that too, but I need to rebind that event handler
after an Ajax call. The following works, but seems ugly. Any pointers?
$(document).ready(function() {
function bindBuilding() {
$('a.edit-building').click(function(){
var building = function (data) {
//do stuff
}
$.get(this, null, building);
return false;
});
}
bindBuilding();
function doAjaxStuff() {
//perform ajax stuff
bindBuilding();
}
});
On Oct 2, 11:03 am, "Leonardo K" <leo...@gmail.com> wrote:
> Why don't use the simple click function?
>
> $('a.edit-building').click(function(){
> //do stuff
> return false;
>
> });
> On Thu, Oct 2, 2008 at 14:43, light-blue <Sean.Wing...@gmail.com> wrote:
>
> > Hopefully simple problem. I click an img link, html like this
>
> > <a class="edit-building" href="/edit-building/145">
> > <img src="icons/edit.png"/>
> > </a>
>
> > jquery like this
>
> > if ($(event.target).is('a.edit-building')) {
> > var building = function (data) {
> > ..do stuff
> > }
> > $.get(event.target, null, building);
> > return false;
> > }
>
> > but the binding doesn't work, probably because the target is my img
> > not my link. How can I click the image and fire the code for my a.edit-
> > building?
>
> > Thanks!
No comments:
Post a Comment