- admin.py
class TestAdmin(admin.ModelAdmin):
class Media:
js = (
'js/common.js',
)
list_display = ['custom_actions']
def custom_actions(self, obj):
return mark_safe(
'<a class="button call_alert" href="#" data-msg="A">A</a> '
'<a class="button call_alert" href="#" data-msg="B">B</a>'
)
custom_actions.short_description = 'Custom Actions'
admin.site.register(Test, TestAdmin)
- js/common.js
(function($) {
$(".call_alert").on("click", function() {
alert($(this).data("msg")); // ★★★ Dose not!!! ★★★
});
})($);
error message :
Uncaught TypeError: $ is not a function at common.js:2 at common.js:5
Is there a way to display the alert message?
Any potential solutions?
Your help is greatly appreciated.