render_model templatetag should create unique classnames #2822

stefanfoulis opened this Issue Mar 6, 2014 · 4 comments

4 participants

Divio AG member

The {% render_model post "myfield" "myfield" "" safe %} templatetag generates a class on the wrapping div that is used in JS (<div class="cms_plugin cms_plugin-myapp-mymodel-myfield-2 cms_render_model"><p>asdfadsf</p></div>).

If the same model is used multiple times on the same page (e.g a list of blog posts and another list of the same blog post in a "latest posts" plugin in the sidebar). The same class (cms_plugin-myapp-mymodel-myfield-2) is used twice on the same page.

The current effect is that the window openen on doubleclick is not positioned correctly. But it might have other issues as well.

blog-post-placeholder-edit-window wrong-position

@digi604 digi604 added this to the 3.0 milestone Mar 6, 2014
@digi604 digi604 added the blocker label Mar 6, 2014
Divio AG member

@yakky maybe you might have a quick solution?


Quick and dirty solution, which will require to rework tests a bit, is to add a randomization here and in the cms-plugin-whatever DOM class.
The class name is built to be unique per instance but totally deterministic.
Or, we can add a mode parameter to the render_model templatetag and use it in the DOM class name; in this case, it's up to the user to pass the correct mode for every use; something like:

{% render_model post 'abstract' '' '' '' 'main' %}


{% render_model post 'abstract' '' '' '' 'plugin' %}
Divio AG member

but isn't this just some JS problem?


There are two failing assumptions in this bug:

  1. Every frontend-enabled DOM element shalt be unique per page
  2. Every frontend-enabled model instance shalt be unique per page

I don't know if @FinalAngel can overcome the first one in the javascript, I can try to patch the second one in the plugin.html template

@FinalAngel FinalAngel added a commit to FinalAngel/django-cms that referenced this issue Mar 10, 2014
@FinalAngel FinalAngel fixes issue #2822 208afee
@digi604 digi604 closed this Mar 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment