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

generic JS usable when a row is duplicated when file is a part of a ManyToMany #463

Merged
merged 3 commits into from Jan 10, 2015

Conversation

DylannCordel
Copy link
Contributor

How to reproduce :

Use a FilerField in a ManyToMany, and use admin's inline to manage it in the admin form.
When "add new row" is clicked, the "clear" image is displayed and not functionnal.

This is because the old javascript is for the current ID, so new lines, with != IDs, couldn't work. This bug fix use classes and the jQuery(document).on function to watch event on newly created lines.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling f5f7c22 on webu:bugfix/js-m2m into 021541e on stefanfoulis:master.

//if this file is included multiple time, we ensure that filer_clear is attached only once.
$(document).off('click.filer', '.filerFile .filerClearer', filer_clear).on('click.filer', '.filerFile .filerClearer', filer_clear);
});
})(jQuery);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be django.jQuery to use the django-namespaced jQuery
Could you fix that?

@yakky
Copy link
Member

yakky commented Jan 9, 2015

Other than the above comment, LGTM, thanks @DylannCordel

@DylannCordel
Copy link
Contributor Author

django.jQuery is now used in filer/static/filer/js/widget.js and filer/static/filer/js/popup_handling.js

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 7b5fcc1 on webu:bugfix/js-m2m into 021541e on stefanfoulis:master.

@yakky
Copy link
Member

yakky commented Jan 10, 2015

awesome!

yakky added a commit that referenced this pull request Jan 10, 2015
generic JS usable when a row is duplicated when file is a part of a ManyToMany
@yakky yakky merged commit ffc3480 into django-cms:master Jan 10, 2015
@yakky
Copy link
Member

yakky commented Jan 10, 2015

Thanks @DylannCordel

@DylannCordel DylannCordel deleted the bugfix/js-m2m branch March 31, 2015 15:13
@DylannCordel DylannCordel restored the bugfix/js-m2m branch August 1, 2015 08:32
DylannCordel added a commit to webu/django-filer that referenced this pull request Aug 3, 2015
@DylannCordel
Copy link
Contributor Author

Hi @evildmp

I'll add a new paper marked "IE" in my "angry box"... Fixed in #568

Straight from the (recent) jQuery source :

// We can't allow the type property to be changed (since it causes problems in IE)
if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
    throw "type property can't be changed";

IE, Glue eater

@DylannCordel
Copy link
Contributor Author

Hi @stefanfoulis

You right, but this is corrected since 10 january on this commit : 7b5fcc1
See https://github.com/stefanfoulis/django-filer/pull/463#issuecomment-69449705

@evildmp
Copy link
Contributor

evildmp commented Aug 7, 2015

@DylannCordel The issue is affecting me in Safari though. With the change in #568 I now see:

[Error] TypeError: undefined is not a function (evaluating '$(document).off('click.filer', '.filerFile .filerClearer', filer_clear)')
    (anonymous function) (widget.js, line 18)
    ready (jquery.js, line 392)
    DOMContentLoaded (jquery.js, line 745)

@evildmp
Copy link
Contributor

evildmp commented Aug 7, 2015

I should add that the Filer widget itself now appears to work, even though I get that error, but I still find that it breaks other JS that my admin relies on.

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.

None yet

5 participants