:mod:`turbo.classes` ==================== .. py:module:: turbo.classes Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: turbo.classes.ModelBroadcast turbo.classes.Turbo turbo.classes.TurboRender Attributes ~~~~~~~~~~ .. autoapisummary:: turbo.classes.APPEND turbo.classes.PREPEND turbo.classes.REPLACE turbo.classes.UPDATE turbo.classes.REMOVE turbo.classes.BEFORE turbo.classes.AFTER turbo.classes.SELECTOR_CSS turbo.classes.SELECTOR_ID turbo.classes.SELECTOR_TYPES .. data:: APPEND :annotation: = append .. data:: PREPEND :annotation: = prepend .. data:: REPLACE :annotation: = replace .. data:: UPDATE :annotation: = update .. data:: REMOVE :annotation: = remove .. data:: BEFORE :annotation: = before .. data:: AFTER :annotation: = after .. class:: ModelBroadcast(model) .. data:: SELECTOR_CSS :annotation: = css .. data:: SELECTOR_ID :annotation: = id .. data:: SELECTOR_TYPES .. class:: Turbo A reference to a specific broadcast. Broadcast names can be provided as strings or can be generated by passing in a django instance. Eg: Turbo('broadcast_name') Turbo(django_instance) .. method:: _init_with_str(self, stream_name = '') .. method:: _init_with_model(self, stream_target) .. method:: update_stream_name(self) .. method:: render(self, template_name, context=None) Returns a TurboRender object from a django template. This rendered template can then be broadcast to subscribers with the TurboRender actions (eg: append, update, etc...) Takes a template name and context identical to Django's render() method. .. method:: render_from_string(self, rendered_template) Returns a TurboRender object from a string. .. method:: remove(self, selector=None, id=None) Send a broadcast to remove an element from a turbo frame. .. class:: TurboRender(stream_name, rendered_template = '') A rendered template, ready to broadcast using turbo. .. method:: append(self, selector=None, id=None) Add a target action to the given selector. .. method:: prepend(self, selector=None, id=None) Add a target action to the given selector. .. method:: replace(self, selector=None, id=None) Add a target action to the given selector. .. method:: update(self, selector=None, id=None) Add a target action to the given selector. .. method:: remove(self, selector=None, id=None) Add a target action to the given selector. .. method:: before(self, selector=None, id=None) Add a target action to the given selector. .. method:: after(self, selector=None, id=None) Add a target action to the given selector. .. method:: _add_target(self, selector, id, action) .. method:: _render_frame(self, selector_type, selector, action) .. method:: _broadcast(self, rendered_frame)