-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use jquery agnostic wrapping "inner code" #51
Conversation
this way you can e.g. load all of your javascript at the bottom of the page - including jquery :)
I do not understand why do we have to do that. Furthermore, this is not compatible with IE8. jQuery's dom ready provides cross-browser api, so why do we need to take a reverse approach? |
Otherwise you have to load jquery before the forms are rendered - and I prefer loading it (just like all the rest of my javascripts) at the bottom of the page. Personally, I can do without IE8 - but generally that is a valid issue, that I didn't think of! |
Maybe you can try using |
* Previously, when using {{ form.empty_form }} the inline js would automatically be called on the `empty_form`. This made it impossible to dynamically add inlines to the page because of how `__prefix__` is duplicated to the new inlines. This commit wraps all the inline js in a function which is attached to global `window.django_select2` plugin. On page load only non `empty_form`'s are initialized with select2, giving the developer to attach to the 'add new inline' click and call the `django_select2` plugin with the proper inline formset id. I am using this now with `django-superformset` and dynamically inserted inlines that contain select2 fields are working as expected. Additionally all the inline js for each formset is identicaly, a future cleanup could be to only inline the field and form id variables. * First converted `widgets.py` to Unix file type so the diff does not contain windows line endings. * Since all the inline js is now run post page load, we can put all of the`django_select2` js libraries at the page bottom with other js assets. refs applegrew#51 * As a bonus, this removes all the js code generation libs from utils with json.dumps(). * I have not tried formsets with the django admin, however this work will allow inline formsets support to be added to the admin with less developer effort than before. Refs: applegrew#125, applegrew#65, applegrew#49, applegrew#32, applegrew#109
* Previously, when using {{ form.empty_form }} the inline js would automatically be called on the `empty_form`. This made it impossible to dynamically add inlines to the page because of how `__prefix__` is duplicated to the new inlines. This commit wraps all the inline js in a function which is attached to global `window.django_select2` plugin. On page load only non `empty_form`'s are initialized with select2, giving the developer to attach to the 'add new inline' click and call the `django_select2` plugin with the proper inline formset id. I am using this now with `django-superformset` and dynamically inserted inlines that contain select2 fields are working as expected. Additionally all the inline js for each formset is identicaly, a future cleanup could be to only inline the field and form id variables. * First converted `widgets.py` to Unix file type so the diff does not contain windows line endings. * Since all the inline js is now run post page load, we can put all of the`django_select2` js libraries at the page bottom with other js assets. refs applegrew#51 * As a bonus, this removes all the js code generation libs from utils with json.dumps(). * I have not tried formsets with the django admin, however this work will allow inline formsets support to be added to the admin with less developer effort than before. Refs: applegrew#125, applegrew#65, applegrew#49, applegrew#32, applegrew#109
* Previously, when using {{ form.empty_form }} the inline js would automatically be called on the `empty_form`. This made it impossible to dynamically add inlines to the page because of how `__prefix__` is duplicated to the new inlines. This commit wraps all the inline js in a function which is attached to global `window.django_select2` plugin. On page load only non `empty_form`'s are initialized with select2, giving the developer to attach to the 'add new inline' click and call the `django_select2` plugin with the proper inline formset id. I am using this now with `django-superformset` and dynamically inserted inlines that contain select2 fields are working as expected. Additionally all the inline js for each formset is identicaly, a future cleanup could be to only inline the field and form id variables. * First converted `widgets.py` to Unix file type so the diff does not contain windows line endings. * Since all the inline js is now run post page load, we can put all of the`django_select2` js libraries at the page bottom with other js assets. refs applegrew#51 * As a bonus, this removes all the js code generation libs from utils with json.dumps(). * I have not tried formsets with the django admin, however this work will allow inline formsets support to be added to the admin with less developer effort than before. Refs: applegrew#125, applegrew#65, applegrew#49, applegrew#32, applegrew#109
this way you can e.g. load all of your javascript at the bottom of the page - including jquery :)