Skip to content

Instantly share code, notes, and snippets.

@3cp
3cp / app.html
Last active October 12, 2016 02:47
valueChanged
<template>
<require from="./line"></require>
<button click.delegate="update()">update</button>
<svg width="100" height="100">
<line
repeat.for="value of values"
value.bind="value"
label.bind="labels[value]"
></line>
</svg>
@3cp
3cp / app.html
Last active May 2, 2018 06:56 — forked from jdanyow/app.html
input event trigger
<template>
<input value.bind="message">
<br>
<p>Message: ${message}</p>
<button click.trigger="tryChange()">jQuery('input').val('test').trigger('change')</button>
<button click.trigger="tryInput()">jQuery('input').val('test2').trigger('input')</button>
</template>
@3cp
3cp / app.html
Last active October 12, 2017 05:56
test error in attached
<template>
<require from="./child"></require>
<child if.bind="stage == 1">first</child>
<child if.bind="stage == 2">second</child>
<button click.delegate="stage = 1" disabled.bind="stage == 1">Previous</button>
<button click.delegate="stage = 2" disabled.bind="stage == 2">Next</button>
</template>
@3cp
3cp / app.html
Last active November 7, 2017 01:15
highchart
<template>
<require from="./line-chart"></require>
<button click.trigger="doAgain()">New data</button>
<line-chart charges.bind="charges"></line-chart>
</template>
@3cp
3cp / app.css
Last active February 20, 2018 05:10
highlight "products" route menu when on "product/:id" page
.nav-bar {
margin: 1rem;
}
.nav-bar a {
margin: .5rem 1rem;
padding: .5rem;
font-size: 1.2rem;
}
.nav-bar a.active {
@3cp
3cp / app.html
Last active February 23, 2018 00:15
as-element
<template>
<require from="./my-comp"></require>
<h4 as-element="my-comp"></h4>
<h4 as-element="compose" view-model="./my-comp"></h4>
</template>
@3cp
3cp / app.html
Last active February 27, 2018 21:30
inheritBindingContext
<template>
<require from="./my-comp"></require>
<my-comp></my-comp>
</template>
@3cp
3cp / app.html
Last active March 12, 2018 21:52 — forked from Alexander-Taran/app.html
Promise edit pattern
<template>
<template if.bind="editMode">
<input value.bind="editValue">
<button click.delegate="save()">save</button>
<button click.delegate="editMode = false">cancel</button>
</template>
<template else>
<h1>${message} <button click.delegate="enterEditMode()">edit</button></h1>
</template>
</template>
<template>
<require from="./dyn-field"></require>
<form>
<dyn-field
repeat.for="prop of properties"
label.bind="prop.label"
value.bind="model | get:model:prop.expression"
errors.bind="errors | get:errors:prop.expression"></dyn-field>
</form>
@3cp
3cp / app.html
Last active May 29, 2018 04:33
select init
<template>
<p>select with repeat.for options. foo = ${foo}</p>
<select value.bind="foo">
<option repeat.for="opt of ['one', 'two']" model.bind="opt">${opt}</option>
</select>
<p>select with one option + repeat.for options. foo2 = ${foo2}</p>
<select value.bind="foo2">
<option value="one">one</option>
<option repeat.for="opt of ['two']" model.bind="opt">${opt}</option>