Giter Club home page Giter Club logo

channelbindjs's Introduction

ChannelBindJS

Activates elements for inline editing and live updating from a django-channels backend. This script looks for expected class names and data attributes and adds events and attributes to connect them.

The aim of this script is to be small and easy to use rather than being high-performance of highly featured. Compatibility is for modern browsers.

Any html element containing a representation of a django model can be activated by adding classes to it and its enclosed field values.

On the container:

  • class="live"
  • data-model="appname.modelname"
  • data-id="1" // primay key

On each field:

  • class="field" // to enable live udpates
  • class="editable" // to enable inline editing
  • data-field="fieldname"

This object depends on the channels.WebSocketBinding and should be initialised with the binding url of the demultiplexer set up in channels routing.

Include the script:

<script src="/static/channels/js/websocketbridge.js"></script> 
<script src="/static/channelbindjs/activate.js"</script> 
<script>Activation.init('/binding/');</script> 
</body> 

And to make a model receive live updates and have inline editing:

<div class="live" data-model="appname.modelname" data-id="1" data-stream="demultiplexer-stream">
  <header>
    <div class="field editable" data-field="title">Rendered content of title field</div>
  </header>
  <div class="field editable" data-field="description">Rendered description</div>
</div>

Installation

pip install channelbindjs

Links

Channels data binding documentation

channelbindjs's People

Contributors

moaxey avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.