1👍
The problem was that the code was under the $(document).ready(function()) which is why it was not able to get the value at that time. I took my functions outside the document.ready method and its working now!
0👍
Make sure that your javascript is running without error and it is above your modal. Your modal is getting compiled before your javascript runs and so that data cannot be fetched when you click on modal.
- NOT NULL constraint failed: device_api_devicegroup.owner_id
- How to solve the error with migration django?
- Django, accessing meta properties outside of the page that generates them
- Django client does not delete in test
0👍
I’m an not familiar with Django
templates, but your markup suggests perhaps the template is not being rendered until openModal() is called. Is this the case?
If so, then you would need to run your auto-select code after the modal’s <option>
elements have been rendered.
To test this you could put a console.log inside your for loop, to check which options are available when the click event happens.
for (var i=0; i<product_select.options.length; i++){
console.log(product_select.options[i])
}
- How to sum all integer properties from ForeignKey objects in django template?
- Django rest_social_auth log in. What to do with facebook token?