Hi,

I'm not sure if this is the correct approach or not.. But i'm finding the 
trigger event in the DateTimeShortcut.js is not triggering changes when you 
click on a date. I've done something similar to the following:

*admin.py*

class CustomAdmin(admin.ModelAdmin):
...
    class Media:
        js = (

       'js/moment.min.js',
       'apps/core/custom_script.js',
   )



*apps/core/custom_script.js*
 (function($) {
     $(function () {
       $("input#id_start_date[type='text']").change(function(){
            alert("element changed");
        });
    });

})(django.jQuery);

If I modify the DateTimeShortcut.js in django source so that `
django.jQuery(DateTimeShortcuts.calendarInputs[num]).trigger("change");` is 
called before the focus() and 
after DateTimeShortcuts.calendarInputs[num].value is set it works as 
expected. Is there an easier/better way to do this? Do i need to create a 
PR with the affect lines patched?

*django/contrib/admin/static/admin/js/admin/DateTimeShortcut.js*

...
415:    DateTimeShortcuts.calendarInputs[num].value = new Date(y, m - 1, 
d).strftime(format);
416:   
 django.jQuery(DateTimeShortcuts.calendarInputs[num]).trigger("change"); 
 // PATCH
417:    DateTimeShortcuts.calendarInputs[num].focus();

Running Django==1.10.1

thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7849bcc0-51c6-4667-90c1-e1d9a775b68c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to