django-unicorn icon indicating copy to clipboard operation
django-unicorn copied to clipboard

Combining ```unicorn:view``` and ```unicorn:poll``` features gives error ```The 'control' component appears to have multiple root elements.```

Open wallem89 opened this issue 11 months ago • 1 comments

I want to combine unicorn:view and unicorn:poll features in one Django template. I have this working but this gives the following warning:

The 'control' component appears to have multiple root elements.

My current templates/unicorn/control.html is as follows:

...
% block content %}
<div unicorn:view unicorn:poll="get_updates">
...

And my components/interface.py:

...
class InterfaceView(UnicornView):

    def __init__(self, *args, **kwargs):
        super().__init__(**kwargs)
        self.name = kwargs.get("name")
        
    @method_decorator(login_required)
    def dispatch(self, *args, **kwargs):
        return super(InterfaceView, self).dispatch(*args, **kwargs)
    
    def get_updates(self):
        print('Updating page with poll')
            
        self.current_time = now()
        return PollUpdate(timing=1000, disable=False, method="get_updates")
...

I tried different combinations of unicorn:view and unicorn:poll but they fail completely or give the same warning. I cannot find any source that tells how to combine different Unicorn features.

wallem89 avatar Mar 07 '24 14:03 wallem89

Thanks for the error report! @mihrab34 is going to take a look at this issue and see if there is a straight-forward solution.

adamghill avatar Jul 26 '24 22:07 adamghill