django-filebrowser-no-grappelli icon indicating copy to clipboard operation
django-filebrowser-no-grappelli copied to clipboard

Inlines problem

Open aronchi opened this issue 14 years ago • 5 comments

When I try to use a filebrowser in inlines inside admin, it doesn't catch the correct id for the field, because it leaves prefix in the id instead replacing the number of the inline.

aronchi avatar Aug 26 '10 14:08 aronchi

I've seen that it returns that error only for new inlines. because inlines.js doesn't replace this piece of code prefix

aronchi avatar Aug 26 '10 14:08 aronchi

Thank you for the bug report.

I haven't tried using file browser fields in inlines so I'm afraid I can't help much. Sounds like it would also be an issue for upstream.

wardi avatar Aug 26 '10 15:08 wardi

I just ran into this and made a quick fix by modifying inlines.js and including it in the page after the original django version. add this bit starting at line 78.

.end()
.filter(function() {
    var el = $(this).next();
    return el.attr("href") && el.attr("href").search(/__prefix__/) >= 0;
}).each(function() {
    var el = $(this).next();
    el.attr("href", el.attr("href").replace(/__prefix__/g, nextIndex));
});

egolts avatar Dec 03 '10 21:12 egolts

great, send me a patch or pull request and I'll include it

wardi avatar Dec 17 '10 15:12 wardi

Hi, I have commited a fix (for tabular inlines only at the moment). The trick is to override the tabular inline template and add a post-add hook in the javascript to correct the field id in the filebrowser function call. See:

https://github.com/aleray/django-filebrowser-no-grappelli/commit/1c3389bfae7c595ea20005498944e4545e7b9e0e

aleray avatar Jan 20 '11 02:01 aleray