отделение jQuery onclick для нажатия на href в отделении

Ни одно из вышеупомянутого. Просто используйте admin.site.unregister (). Вот то, как я недавно добавил Пользователей фильтрации на is_active в администраторе ( n.b. фильтрация is_active находится теперь на модели User по умолчанию в ядре Django; все еще работы здесь как пример), весь DRY, как может быть:

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

class MyUserAdmin(UserAdmin):
    list_filter = UserAdmin.list_filter + ('is_active',)

admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
7
задан Al. 23 October 2009 в 19:41
поделиться

3 ответа

The problem here is that a lies within the tr. Ergo, when the a click() method is triggered, the event bubbles to the tr containing it, creating the recursive loop you mentioned. Rather than call .find('a').click(), have both a and tr use the same click method.

$('tr, a').click(function(){
   //dostuff
   return false;
});
9
ответ дан 6 December 2019 в 10:51
поделиться
$(document).ready(function(){
  $('table.products tr').click(function(e){
    e.stoPropagation(); // for stop the click action (event)
    $(this).find('a').click();
    return false;
  });
});
-2
ответ дан 6 December 2019 в 10:51
поделиться

First, I would console.log($(this).find('a')) and make sure it is the appropriate link. Next, I believe the click event is not what you want on the a element. I think you just want: var a = $(this).find('a'); if (a) document.location.href = a.attr('href');

My JavaScript is pretty weak though : )

0
ответ дан 6 December 2019 в 10:51
поделиться
Другие вопросы по тегам:

Похожие вопросы: