Simple, lightweight, persistent two-way databinding

Related tags

Frameworks way.js
Overview

way.js

Gitter

Simple, lightweight, persistent, framework-agnostic two-way databinding Javascript library.
With no to little JS code to write. And no dependencies.

Demo
Codepen
jsFiddle

Buy us coffee: Gittip
Follow us on Twitter: @way_js

The following documentation is also available in Chinese (credits: @wuyunjiang).

Quick start

Declare an HTML element with some tags.

  <form way-data="myFormData" way-persistent="true">
  	<input type="text" name="name">
  	<input type="text" name="age">
  	<input type="text" name="gender">
  </form>

  Name: <span way-data="myFormData.name"></span>

Boom. Now every change in the form will be stored in-memory. The bound span's html will be changed on the fly. And the bound data will be persistent, meaning your HTML will be populated with your data on page reloads.

Enough talk, see it in action.

Installation

[Step 1] Include the library to your page.

1.a. via NPM

npm install way-js

then

import 'way-js';

1.b. or

<script src="dist/way.js"></script>

[Step 2] There is no step 2. You are good to go.

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to way-, as in way-data="". Set these options to the elements that have to be bound.

Name Type Default Description
data string null Allows to define the dot separated path where the data will be stored. Can include arrays. When used on a form, a json variable made of all the included inputs with a [name] attribute will be created and stored in the specified storage. Pass the "__all__" path to access all way.js' data.
default string null A link to a default data to set on an element, in case there is no bound value.
persistent boolean true Allows to store the data to localStorage everytime the bound data changes.
readonly boolean false Prevents the element changes from resetting the bound value.
writeonly Boolean false Prevents the element from getting changed when the bound value changes.
json boolean false Returns pretty-printed json data to its DOM element.
html boolean false Declares whether the data attributed to an element should be parsed as HTML or not.
pick array null A comma separated list of values to pick (in forms only) to sync with the storage. By default, all form inputs are synced.
omit array null A comma separated list of values (in forms only) to not sync with the storage. By default, no form input is omitted.

Some examples:

<form way-data="some.form" way-pick="some,properties,that,can.be.nested">
<form way-data="some.form" way-omit="dont,want.those">
<img way-data="some.image" way-default="http://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png">
<pre way-data="some.json" way-json="true"></pre>

Scopes

You can set scopes to your DOM elements' data.

[way-scope] attribute
Passing this attribute to an element will point all its children's "way-data" attributes to this scope. Scopes can be nested.

way.set("someScope", { with: { something: "hello" }})
<div way-scope="someScope">
  <div way-scope="with">
    <div way-data="something"></div> <!-- Will render "hello" -->
  </div>
</div>

[way-scope-break] attribute
Breaks a scope chain. All the child elements of this one will have no scope set.

way.set("someScope", { with: { something: "hello" }})
<div way-scope="someScope">
  <div way-scope-break="true">
    <div way-data="someScope.with.something"></div> <!-- Will render "hello" -->
  </div>
</div>

scope() method
Returns the scope of a given DOM element

<div way-scope="someScope">
  <div way-scope="with">
    <div way-data="something" id="someDIV"></div>
  </div>
</div>
way.dom("#someDIV").scope()  
>> "someScope.with"

Repeats

Duplicates a DOM element for each of the values it can loop through in a way.js' passed data.
Notes:

  • Repeat blocks automatically set the appropriate scope to their child elements.
  • On each loop, "$$key" corresponds to the key of the current element looped.

Having this:

way.set("some.list", [
	{name:"Pierre"},
	{name:"Paul"},
	{name:"Jacques"}
]);
<div way-repeat="some.list">
	$$key - <span way-data="name"></span>
</div>

Will render that:

<div way-scope="some.list">
  <div way-scope="0">
    0 - <span way-data="name">Pierre</span>
  </div>
  <div way-scope="1">
    1 - <span way-data="name">Paul</span>
  </div>
  <div way-scope="2">
    2 - <span way-data="name">Jacques</span>
  </div>
</div>

Transforms

Transforms the displayed data bound to your DOM elements.

[way-transform] attribute
Pass transform functions by name. Add multiple transforms by separating them with the "|" symbol.
In case of conflicts between transforms, the last mentionned transform wins.
Some pre-build transforms [PR welcome for more!]

Name Description Example
uppercase Sets a string to uppercase "hello" becomes "HELLO"
lowercase Sets a string to lowercase "HELLO" becomes "hello"
reverse Reverses a string "hello" becomes "olleh"
way.set("someData", "hello")
<div way-data="someData" way-transform="uppercase"></div>
<!-- Renders "HELLO" -->

registerTransform(name, transform) method
Adds a new transform.

way.set("someData", "hello");
way.registerTransform("lolify", function(data) {
  return data + " lol";
});
<div way-data="someData" way-transform="lolify|uppercase"></div>
<!-- Renders "HELLO LOL" -->

Helper elements

Allows to perform simple tasks on your way.js' data with a click.

Attribute Description
way-action-remove Removes a way data
way-action-push if provided with an array, pushes an null value to it

Example:

way.set("some.list", ["I", "am", "list"]);
<div id="clickToRemove" way-action-remove="some.list.2"></div>
<div id="clickToPush" way-action-push="some.list"></div>
$("#clickToRemove").click();
$("#clickToPush").click();
way.get("some.list");
>> ["I", "am", null]

Helper classes

For images only way.js adds classes to your DOM elements to easily detect load / error / success statuses with the data they get passed.

Class Description
way-loading When an image is getting downloaded to a DOM element
way-error When no image is returned from the URL provided
way-success When... Well, you got it.
way.set("image.url", "somethingThatsNotAnImageURL");
<img way-data="image.url">
<!-- Gets a class ".way-error" attributed -->

Methods

Everything should be done for you from the HTML tags. But if necessary, you can also use helper functions to interact with your stored data and DOM elements.

Notes:

  • [element] refers to the CSS selector of a DOM element.
  • [options] is optional. By default, options are read from the HTML tags of the elements. But you can overwrite them, by passing this parameter.

DOM methods

way.dom(element).toStorage(options)
Stores the element's value to the in-store memory.

way.dom("#someForm").toStorage()

way.dom(element).fromStorage(options)
Sets the element's value from the stored one.

way.dom("#someForm").fromStorage()

way.dom(element).toJSON(options)
Returns a JSON with the parsed data of the input (particularly handy for forms).

way.dom("#someForm").toJSON()

>> {
		its: "values",
		serialized: {
			in: "a json"
		}
	}

way.dom(element).fromJSON(data, options)
Sets the element's value from any data (in json).

way.dom("#someForm").fromJSON({name:"John Doe"})

way.dom(element).getValue()
Returns a structured JSON containing the value of the DOM element.

way.dom("#someForm").getValue()

way.dom(element).setValue(value, options)
Sets the element's value from any data (in json).

way.dom("#someForm").setValue({name:"John Doe"})

way.dom(element).setDefault(force)
Sets the default value of an element. By default, only the DOM element gets its value set to the default value. Its bound value in the datastore in unchanged. Pass a [force] parameter if you need to force setting in-memory value of this data to the element's default value.

way.dom("#someForm").setDefault()

way.setDefaults(force)
Sets all the default values of bound DOM elements.

way.setDefaults()

way.dom(element).getOptions()
Returns the list of the ["way-"] options attributed to a DOM element.

way.dom("#someForm").getOptions()

Data methods

way.get(selector)
Returns the value of the data stored under a given pathname.

way.get("some.path");
>> "bonjour"

way.set(selector, value, options)
Saves the data in memory under the specified pathname.

way.set("some.path", "bonjour!");

way.remove(selector, options)
Removes the data stored under a given pathname.

way.remove("some.path");
way.get("some.path");
>> undefined

way.clear(options)
Clears all the data

way.clear();
way.get();
>> {}

localStorage methods

way.backup()
Stores the data saved in way.js' datastore to localStorage.

way.backup();

way.restore()
Restores the data saved in localStorage. Called on $(document).ready by default (can be changed with global options).

way.restore();

Binding methods

way.registerBindings()
Triggers a scan of the DOM to find and save the elements with the [way-data] attribute, that will be bound with some data.

way.registerBindings()

way.updateBindings(selector)
Sets the value of all the DOM elements binded to a data selector with their values in way.js' datastore. If omitted, all (excluding write-only's and omitted) DOM elements with a "way-data=" attribute will be refreshed.

way.updateBindings("formData.name")

Repeat methods

way.registerRepeats()
Triggers a scan of the DOM to find and save the elements with the [way-repeat] attribute, that will be bound with some data.

way.registerRepeats()

way.updateRepeats(selector)
Triggers a refresh of the repeat elements with their respective data.

way.updateRepeats("somethingToBeLooped")

Watcher methods

way.watch(selector, callback[value])
Watches changes of a given value.

way.watch("some.data", function(value) {
	console.log("Data has been updated to value: " + value);
});

way.watchAll(callback[selector, value])
Watches all changes in way.js' datastore.

way.watchAll(function(selector, value) {
	console.log("The data " + selector + " has been changed.", value);
});

Global options

way.options.persistent (Boolean)
Sets whether or not data will be restored from localStorage on document.ready (true by default).

way.options.persistent = true

way.options.timeoutInput (Number)
Number of milliseconds of the timeout between keypresses on bound elements to store their values to the datastore (50 by default).

way.options.timeoutInput = 50

way.options.timeoutDOM (Number)
Number of milliseconds of the timeout between scans of the DOM to list bound elements on each DOM change (500 by default).

way.options.timeoutDOM = 500

To do

  • document a bit more the code
  • test
  • enjoy

Integrations

  • [Meteor] To be coming

Contribute

  • Fork & pull request.
  • If you planning add some feature please create issue before.

Otherwise changes will be rejected.

Licence

The MIT License

Copyright (c) 2014 Gwendall Esnault [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Filter function

    Filter function

    In AngularJs, it has a functionality that allow you to specify the format function for data. https://docs.angularjs.org/api/ng/filter

    For instance,

    {{myData | uppercase}}

    If myData='aabbcc', the content will be displayed as 'AABBCC'.

    Is it possible to add such similar feature?

    opened by vincentma 9
  • Framework agnostic?

    Framework agnostic?

    How can you label this as framework agnostic when it includes and depends on jQuery? That warning should be in the same line as the "include this one file" happy-doc in the README.

    opened by walterdavis 8
  • Use `input`-event instead of `change keyup`-event

    Use `input`-event instead of `change keyup`-event

    The input-event is triggered when the contents of a field change, even when you paste something with the mouse. This also eliminates the event firing multiple times when nothing changes when you use, for example, the arrow keys.

    opened by justim 5
  • How to do nested repeats?

    How to do nested repeats?

    I have json like

     { "services": {
            "java": {
                "package": ["java6", "java7", "java8"],
                "type": ["local", "remote"]
            },
           "php": {
                "package": ["php5-cli", "php5-fpm"],
                "type": ["local", "remote"]
            }
        }
    } 
    

    And I want to do somethink like:

     <div way-repeat="services">
             $$key
             <div way-repeat="services.package">$$key</div>                  
     </div>
    

    And nesting can be deeper Is it possible?

    opened by clicman 4
  • Chinese documents(中文文档)

    Chinese documents(中文文档)

    way.js中文文档(Github官方文档翻译)

    Gitter

    先附英文原文地址:https://github.com/gwendall/way.js

    简单的、轻量级的、持久的、不依赖任何框架。双向数据绑定的JS库.
    用少量的代码编写. 并且不依赖任何框架.

    官方演示:Demo
    在线编辑,实时演示:Codepen , jsFiddle

    支持我们一下: Gittip
    在Twitter上关注我们: @way_js

    快速开始

    用一些特定标签,声明 HTML 元素

    
      <form way-data="myFormData" way-persistent="true">
      	<input type="text" name="name">
      	<input type="text" name="age">
      	<input type="text" name="gender">
      </form>
    
      Name: <span way-data="myFormData.name"></span>
    
    

    Boom. 现在表单中的每次改变都将会被存储到内存中,被绑定的 span 标签的内容会立即改变。并且被绑定的数据将会持久化保存,这就是说你的页面被重新加载的时候这些数据会自动填充到对应HTML元素上

    说了这么多, 看下在线演示.

    安装

    [首先] 在你的页面中引入way.js库.

    <script src="way.min.js"></script>
    

    [然后] 就没有然后了. 你可以放心去干了

    选项

    你可以通过数据属性或者JavaScripe的方式去控制选项。 数据属性:在名字前面添加 way- ,例如在你需要绑定的html元素上这样使用

    <pre way-data="__all__" way-persistent="true" way-json="true"></pre>
    

    选项名 | 类型 | 默认值 | 描述 ----|------|------ | ---- data | string | null          | 你可以定义.分隔的路径,如Class.StudentList的方式作为way-data的值。它的值能够是数组和json对象。 当用在一个表单form中时,将会创建一个JSON变量,该变量包含所有带有name属性的输入,并存储在指定的内存中。通过__all__访问所有way.js存储的数据. default | string | null | 在一个元素没有绑定数据时候,设置的默认数据 persistent | boolean | true | 是否允许在绑定的数据每次变化的时候,将数据存到本地存储中 readonly | boolean | false | 数据只读. writeonly | Boolean | false | 数据只写. json | boolean | false | 返回标准格式的json数据到DOM元素中,作为元素的element.textContent html | boolean | false | 声明定义了way-data属性的元素是否应该被解析为HTML pick | array | null | 选择表单form中的哪些输入框是与存储数据同步的,用逗号分隔。默认情况下,所有表单中的输入都是同步的。(只能在表单中使用) omit | array | null | 选择表单form中的哪些输入框是与存储数据异步的,用逗号分隔。默认情况下,所有表单中的输入都不是异步的。(只能在表单中使用)

    一些例子:

    <form way-data="some.form" way-pick="some,properties,that,can.be.nested">
    
    <form way-data="some.form" way-omit="dont,want.those">
    
    <img way-data="some.image" way-default="http://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png">
    
    <pre way-data="some.json" way-json="true"></pre>
    

    作用域

    你可以在你的DOM元素数据中设置使用域,这里解释下

    {
      "school":{
        "class1":{
          ...
        }
        "class2":{
          ...
        }
      }
    }
    

    这里的school.class1school.class2各为一个域

    [way-scope] 属性
    通过在元素中使用这个属性,它的所有子孙元素都只能用它way-data指定的数据域下的数据,使用域可以嵌套

    way.set("someScope", { with: { something: "hello" }})
    
    <div way-scope="someScope">
      <div way-scope="with">
        <div way-data="something"></div> <!-- 将渲染 "hello" -->
      </div>
    </div>
    

    [way-scope-break] 属性
    打破使用域规则的束缚. 设置为true后,子孙元素将不受使用域规则束缚,可跨域使用数据

    way.set("someScope", { with: { something: "hello" }})
    
    <div way-scope="someScope">
      <div way-scope-break="true">
        <div way-data="someScope.with.something"></div> <!-- Will render "hello" -->
      </div>
    </div>
    

    scope() 方法
    param:无 return:[String] 指定元素使用的数据所在的域

    <div way-scope="someScope">
      <div way-scope="with">
        <div way-data="something" id="someDIV"></div>
      </div>
    </div>
    
    way.dom("#someDIV").scope()  
    >> "someScope.with"
    

    循环

    循环渲染出数据中的值,如下循环出some.list中的数据

    注意:

    • 重复块会自动设置子元素的数据使用域。(注意第三段代码,第2、5、8行)
    • 每一次循环,$$key 对应的是当前被循环元素的键。(注意第三段代码,第3、6、9行。行首)

    像这样:

    way.set("some.list", [
    	{name:"Pierre"},
    	{name:"Paul"},
    	{name:"Jacques"}
    ]);
    
    <div way-repeat="some.list">
    	$$key - <span way-data="name"></span>
    </div>
    

    将被渲染为:

    <div way-scope="some.list">
      <div way-scope="0">
        0 - <span way-data="name">Pierre</span>
      </div>
      <div way-scope="1">
        1 - <span way-data="name">Paul</span>
      </div>
      <div way-scope="2">
        2 - <span way-data="name">Jacques</span>
      </div>
    </div>
    

    转换

    对你绑定的元素的显示数据进行转换。

    [way-transform] 属性
    通过在元素上设置way-transform属性,值为如下转换名称(也可通过registerTransform添加更多的转化方式),在一个元素上添加多个转换时,使用竖线 | 隔开 万一两个规则发生了冲突,使用最后的那个转换规则 一些预构建的转换 [PR welcome for more!]

    名称 | 描述 | 解释 ----|------|---- uppercase | 将字符串全部设置为大写 | "hello" 变为 "HELLO" lowercase | 将字符串全部设置为小写 | "HELLO" 变为 "hello" reverse | 前后反转字符串 | "hello" 变为 "olleh"

    way.set("someData", "hello")
    
    <div way-data="someData" way-transform="uppercase|reverse"></div>
    <!-- 渲染出 "OLLEH" -->
    

    registerTransform(name, transform) 方法
    添加一个新的转换规则 name:[String] 转换规则名称 transform:[function] 处理函数,参数为原始待处理数据,返回值为处理后的数据

    way.set("someData", "hello");
    way.registerTransform("lolify", function(data) {
      return data + " lol";
    });
    
    <div way-data="someData" way-transform="lolify|uppercase"></div>
    <!-- Renders "HELLO LOL" -->
    

    elements 助手

    当你点击时,可以进行一些简单的任务

    Attribute                  | Description ---- | ------ way-action-remove | 移除指定数据 way-action-push | 如果对象为数组, 就向数组后添加一个null;如果不是数组,就会删除原来值,新值为有一个空对象的数组[null]

    Example:

    way.set("some.list", ["I", "am", "list"]);
    
    <div id="clickToRemove" way-action-remove="some.list.2"></div>
    <div id="clickToPush" way-action-push="some.list"></div>
    
    $("#clickToRemove").click();
    $("#clickToPush").click();
    way.get("some.list");
    >> ["I", "am", null]
    

    Classes 助手

    只对图片有用

    way.js使用一些classes,可以更容易的检测数据的 load/error/success 的状态

    类名 | 描述 ---- | ------ way-loading | 图片加载过程中有效 way-error | 通过url没有获取到图片时有效 way-success | 图片加载成功时有效.

    way.set("image.url", "somethingThatsNotAnImageURL");
    
    <img way-data="image.url">
    <!-- Gets a class ".way-error" attributed -->
    

    方法

    一般数据属性选项都可以完成所有的事,但是有必要的话,你也可以用函数去管理你的数据和页面元素

    注意:

    • [element] 是指一个DOM元素的CSS选择器
    • [options] 时可选择的. 默认情况下, 数据属性选项都在html标签上. 但是你可以通过这些参数覆盖他们.

    DOM 方法

    way.dom(element).toStorage(options)
    存储指定元素的值到内存中

    way.dom("#someForm").toStorage()
    

    way.dom(element).fromStorage(options)
    Sets the element's value from the stored one. 从内存中设置指定元素的值,如果没有设置way-data ,将会设置为__false__

    way.dom("#someForm").fromStorage()
    

    way.dom(element).toJSON(options)
    返回一个JSON格式的input的解析数据 (特别容易得到form的内容).

    way.dom("#someForm").toJSON()
    >> {
    	its: "values",
    	serialized: {
    	    in: "a json"
    	}
    }
    

    way.dom(element).fromJSON(data, options)
    设置任何自定义数据到指定的元素作展示值

    way.dom("#someForm").fromJSON({name:"John Doe"})
    

    way.dom(element).getValue()
    得到指定元素的way-data的值,标准的JSON格式

    way.dom("#someForm").getValue()
    

    way.dom(element).setValue(value, options)
    设置任何自定义数据到指定的元素作展示值

    way.dom("#someForm").setValue({name:"John Doe"})
    

    way.dom(element).setDefault(force)
    设置指定元素值为默认值。通常情况下, 只是设置了DOM元素的值为默认值,并没有在内存中改变它。如果需要,你可以通过设置参数force 强制改变元素在内存中的值。如果元素没有默认值,即为本来的值

    way.dom("#someForm").setDefault()
    

    way.setDefaults(force)
    设置所有绑定的元素的值为默认值

    way.setDefaults()
    

    way.dom(element).getOptions()
    获得指定元素的way-属性列表

      <div id="someForm" way-json="true" way-data="fileTrees.name" way-default="{'a':1}"></div>
    
    way.dom("#someForm").getOptions()
    >> {
    	data:"fileTrees.name",
    	default:"{'a':1}",
    	html:false,
    	json:true,
    	persistent:false,
    	readonly:false,
    	writeonly:false
    }
    

    Data 方法

    way.get(selector)
    通过.路径获得对应的值

    way.get("some.path");
    >> "bonjour"
    

    way.set(selector, value, options)
    设置数据到内存中

    way.set("some.path", "bonjour!");
    

    way.remove(selector, options)
    从内存中移除数据

    way.remove("some.path");
    way.get("some.path");
    >> undefined
    

    way.clear(options)
    清空所有数据

    way.clear();
    way.get();
    >> {}
    

    localStorage 方法

    way.backup()
    保存所有way.js的数据到缓存中

    way.backup();
    

    way.restore()
    恢复保存在本地存储数据。一般在$(document).ready调用。默认情况下(可以通过[全局选项]进行更改)

    way.restore();
    

    Binding 方法

    way.registerBindings()
    触发DOM扫描,发现并保存有way-data的html元素,这些元素将被绑定一些数据

    way.registerBindings()
    

    way.updateBindings(selector)
    使用指定的数据设置所有绑定了数据的DOM元素的值为。如果省略了,所有的(不包括 write-only 和 omitted)DOM元素都将被刷新。

    way.updateBindings("formData.name")
    

    Repeat 方法

    way.registerRepeats()
    触发DOM扫描,发现并保存有way-repeat的html元素,这些元素将被绑定一些数据

    way.registerRepeats()
    

    way.updateRepeats(selector)
    触发一次刷新,使用他们各自的数据刷新重复元素的值 Triggers a refresh of the repeat elements with their respective data.

    way.updateRepeats("somethingToBeLooped")
    

    Watcher 方法

    way.watch(selector, callback[value])
    监听数据中给定的值得变化

    way.watch("some.data", function(value) {
    	console.log("Data has been updated to value: " + value);
    });
    

    way.watchAll(callback[selector, value])
    监听way.js所有数据的变化

    way.watchAll(function(selector, value) {
    	console.log("The data " + selector + " has been changed.", value);
    });
    

    全局选项

    way.options.persistent (Boolean)
    设置在document.ready时,是否从localStorage 中恢复数据(默认true)

    way.options.persistent = true
    

    way.options.timeoutInput (Number)
    绑定元素上的键按下后,将它们的值存储到数据存储中超时的毫秒数 (默认50毫秒).

    way.options.timeoutInput = 50
    

    way.options.timeoutDOM (Number)
    在每个DOM改变后,扫描绑定的元素列表用时,超时的毫秒数 (默认500毫秒).

    way.options.timeoutDOM = 500
    

    翻译

    opened by wuyunjiang 3
  • The sample doesn't work the same between browsers

    The sample doesn't work the same between browsers

    I run the sample code at windows. The browsers i use are firefox31 and chrome35.0.1916.153.

    The sample can get the expected json result in chrome for the option "skills" while in firefox it just come out to the wrong place, just the same level as "formData" in json result.

    Not sure what happened but please have a check, thanks.

    opened by lear2012 3
  • What event to watch for binding ?

    What event to watch for binding ?

    hello there ! First, nice little helper lib you have here.

    Then i have a little question ... i have an input text ( part of a way.repeat() ) that i populate/change value programmatically ... But it seems 'Way' doesn't update the json values when the input is updated.

    What kind of event are you watching to trigger the refresh ? SO that i can trigger it myself whenever the value is updated !

    Thanx a bunch

    opened by kohaistyle 2
  • Repeat fix + functionality extended

    Repeat fix + functionality extended

    • Repeat now re-uses the existing DOM parent element instead of replacing the to-be-repeated item with a DIV. This allows us to e.g. repeat a "tr" inside a "table". Not sure if this will break anything though.
    • After creating the repeated elements, attach event handlers to these new elements specifically so that changes are propagated automatically.
    • Added the possibility to dynamically evaluate JS inside a repeating element, syntax: $${code}, e.g. $${key + 1} will render the list items 1, 2, .. (To make calculation easier I'm now converting the array 'key' (index) to an int)
    opened by mvantzet 2
  • way.js filters

    way.js filters

    These quick and simple filters can be implemented in way.js!

    Currently, you can only filter data that is output from a form (like it is currently in <pre>). This is done through the way-filter HTML attribute. For example way-filter="uppercase" or way-filter="lowercase". Extra filters could be added as necessary. This is to resolve #21.

    Oh, and I should also add that the filters don't seem to like to work on json data. The variable has to have way-json="false" and obviously pointing to something that's not an object :P

    opened by megubyte 2
  • Bug: input cursor is moving when it should not

    Bug: input cursor is moving when it should not

    I was checking out the demo and found a bug. When you're trying to add text not tothe end of the text filed, it switches focus to the end, forcing input to occur at the end.

    Steps: First I write something in the Name field, it works. Then I want to write something to the same field, this time not to the end of it, but to the begging (or in the middle). I can type one symbol where I want it to be, but after that input cursor is moved to the end of the exising string and any successive symbols go to the end.

    opened by MOZGIII 2
  • added check to ignore input[type=file]

    added check to ignore input[type=file]

    Not sure if I should make the pull request here or further upstream.

    But added a small quick check to ignore input[type=file] for now, as js2form, when setting values, would overwrite the values set for input[type=file].

    opened by yinshanyang 2
  • focusing breaks data restoration

    focusing breaks data restoration

    example:

    1. include way.min.js in the header
    2. and then in a script tag i wrote
        jQuery(function ( ) {
            $("#SomeTextArea").focus();
        }
    

    The text area will not be populated with the previously persisted value.

    opened by beppe9000 0
  • Nested repeats are not working

    Nested repeats are not working

    I have this data

    const data = [
      {
        name: '1',
        meta: [{ nested: "1" }]
      }
    ];
    
    <div way-repeat="data">
      <ul>
        <li way-repeat="meta">
          <span way-data="nested"></span>
        </li>
      </ul>
    </div>
    

    This is not working, the inner repeat scope is still same as the outer one :\

    opened by rksh1997 1
  • Can not monitor changes to selection labels?

    Can not monitor changes to selection labels?

    When the monitoring form data is changed, the occurrence of the select tag monitoring failure occurs multiple times. The input tag is normally available

    opened by kifeiLiang 0
Owner
gwendall
📱Senior Freelance Developer - React × React Native × GraphQL
gwendall
Lightweight and powerful data binding.

Rivets.js Rivets.js is a lightweight data binding and templating system that facilitates building data-driven views. It is agnostic about every aspect

Michael Richards 3.2k Dec 28, 2022
Simple and elegant component-based UI library

Simple and elegant component-based UI library Custom components • Concise syntax • Simple API • Tiny Size Riot brings custom components to all modern

Riot.js 14.7k Jan 4, 2023
Functional, simple and customizable UI buttons for react native. Also contains loading functionality and automatically changes color for dual tone buttons. TypeScript support.

React Native UI Buttons ✨ Installation If you want to use icons make sure you have react-native-vector-icons installed in your project. npm install --

Hussain Pettiwala 6 Dec 5, 2022
Simple TypeScript fastify template.

Simple fastify template. Instructions: 1.) Clone the repo 2.) Type npm i to install all dependencies 3.) Type npm run dev to make it autorecompile on

Nick 2 Mar 17, 2022
Zero Two Bot,A fully Modular Whatsapp Bot to do everything possible in WhatsApp by Team Zero Two

?? ???????? ?????? ???? ?? A Moduler WhatsApp Bot designed for both PM and Groups - To take your boring WhatsApp usage into a whole different level. T

Sam Pandey 69 Dec 25, 2022
The missing Javascript smart persistent layer

Basil.js The missing Javascript smart persistence layer. Unified localstorage, cookie and session storage JavaScript API. Philosophy Basil aims to eas

Wisembly 2k Dec 2, 2022
Immutable persistent data collections for Javascript which increase efficiency and simplicity.

Immutable collections for JavaScript Immutable data cannot be changed once created, leading to much simpler application development, no defensive copy

Immutable.js 32.4k Dec 31, 2022
ClojureScript's persistent data structures and supporting API from the comfort of vanilla JavaScript

mori A simple bridge to ClojureScript's persistent data structures and supporting APIs for vanilla JavaScript. Pull requests welcome. Breaking changes

David Nolen 3.4k Dec 31, 2022
Immutable persistent data collections for Javascript which increase efficiency and simplicity.

Immutable collections for JavaScript Immutable data cannot be changed once created, leading to much simpler application development, no defensive copy

Immutable.js 32.4k Jan 7, 2023
Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

BrowstorJS ?? ?? ?? Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all

Nullix 8 Aug 5, 2022
A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YAML support designed to be easy to set up and use

About A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YML

Shuruhatik 5 Dec 28, 2022
Glob-aware two-way copying for git

ggcp git-glob-copy — glob-aware two-way copying for git Requirements Node.js >= 16 Install npm i git-glob-cp # or as a global package npm i -g ggcp U

Anton Golub 3 Jul 5, 2022
Telegram Chatting is a web site-based two-way real-time chat communication application.

Telegram Chatting is a web site-based two-way real-time chat communication application. Has features including two-way private messaging between users, searching user lists, viewing profiles between users, and updating user data.

Nur Muhammad Alif Putra Setiawan 6 Dec 27, 2022
Argon - extension for VS Code and plugin for Roblox allowing easy two-way sync of code and instances

About Argon is a simple two-way sync plugin for Roblox and extension for Visual Studio Code allowing developers not only to sync code but every possib

DARK 16 Dec 29, 2022
Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist ?? ?? ?? ?? ?? The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Mikael Vesavuori 11 Dec 13, 2022
A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles

range-slider-input A lightweight (~2kB) library to create range sliders that can capture a value or a range of values with one or two drag handles. Ex

Utkarsh Verma 42 Dec 24, 2022
🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing ?? About

Mauro de Souza 476 Jan 1, 2023
Pig is a simple two player dice game.

Pig game Pig is a simple two player dice game. Play here: formidablae.github.io/pig_game or formaidablae-pig-game.netlify.app Each turn, a player repe

null 10 Oct 5, 2022
Simple string diffing. Given two strings, striff will return an object noting which characters were added or removed, and at which indices

Simple string diffing. Given two strings, striff will return an object noting which characters were added or removed, and at which indices

Alex MacArthur 196 Jan 6, 2023
This Is A Simple WhatsApp Bot Mode From *DhaniGans* Repo Hope you guys Will like it Repo Updates in Every Two Days

ALIEN ALFA BOT Contact Me: Scan QR Code For Session FORK THIS BEFORE PROCEEDING Use This Button To Fork Now THINGS TO CHANGE IN HEROKU ???????????? ??

TOXIC ALIEN 15 Dec 21, 2022