Javascript File is not responding

19 views
Skip to first unread message

Soumen Khatua

unread,
Jun 25, 2019, 3:56:50 AM6/25/19
to django...@googlegroups.com
Hi Folks,

When I'm using my javasscript/jquery code inside django template then it's working fine but when I'm save it in external file called main.js then it's functionality not responding but url is working.I did all the process but still problem is same??

Myproject:
     |   myproject
     | myapp
     | static
         | css
             | style.css ( this is working fine )
          .....
           | js
              | main.js ( url is working but functionality is not working )   

settings.py :

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'assets')
STATICFILES_DIRS = [
                    ('favicons',os.path.join(BASE_DIR,'static','favicons')),
                    ('images',os.path.join(BASE_DIR,'static','images')),
                    ('css',os.path.join(BASE_DIR,'static','css')),
                    ('js',os.path.join(BASE_DIR,'static','js')),
                    ]
base.html:

{% load staticfiles %}
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> 
<link rel="stylesheet" href="{% static 'css/style.css'%}">
<script type="text/javascript" src="{% static 'js/main.js'%}"></script>

Please help me guys. I attached some screen shot for your better understand.

Thank You.


Regards,
Soumen



javascript file.PNG
javascript product.PNG

Andréas Kühne

unread,
Jun 25, 2019, 6:42:13 AM6/25/19
to django...@googlegroups.com
Hi,

I am guessing that you add this to the <head></head> part of your template? 

I think the problem is that you haven't created the item with the "show-more" class before adding an event listener to it.

Try adding:

$(window).ready(function() {
});

around your js function.

Regards,

Andréas


--
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...@googlegroups.com.
To post to this group, send email to django...@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/CAPUw6WYSeJL0G51A5Osd3D6XAFwtow9tcfKdC7CD_jz144p07Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ravikumar dingari

unread,
Jun 25, 2019, 11:05:24 AM6/25/19
to django...@googlegroups.com
Can U send , How to set Forget Password....In django...With user models

--
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+unsubscribe@googlegroups.com.

Soumen Khatua

unread,
Jun 25, 2019, 1:33:12 PM6/25/19
to django...@googlegroups.com
Thank you for your email.
Now it's woring after added it under Bootstrap link.

Thank You


Regards, 
Soumen



To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
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...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages