Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

nschlemm
Copy link

@nschlemm nschlemm commented Sep 3, 2013

this way you can e.g. load all of your javascript at the bottom of the page - including jquery :)

this way you can e.g. load all of your javascript at the bottom of the page - including jquery :)
@applegrew
Copy link
Owner

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?

@nschlemm
Copy link
Author

nschlemm commented Sep 3, 2013

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!

@applegrew
Copy link
Owner

Maybe you can try using async attribute in script tag of jquery. More info - http://css-tricks.com/thinking-async/

@applegrew applegrew closed this Sep 3, 2013
rizumu added a commit to rizumu/django-select2 that referenced this pull request Sep 11, 2014
  * 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
rizumu added a commit to rizumu/django-select2 that referenced this pull request Sep 11, 2014
  * 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
rizumu added a commit to rizumu/django-select2 that referenced this pull request Sep 11, 2014
  * 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
@rizumu rizumu mentioned this pull request Sep 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants