Ejemplo n.º 1
0
func rangeWatch(r *dom.HTMLInputElement) dom.Element {
	s := xdom.Span()
	xjs.SetInnerText(s, r.Value)
	r.AddEventListener("input", false, func(dom.Event) {
		xjs.SetInnerText(s, r.Value)
	})
	return s
}
Ejemplo n.º 2
0
// NewInput creates a new Input object from the given html input element.
func NewInput(el *dom.HTMLInputElement) *Input {
	// Attempt to determine the type by first getting the type attribute
	// directly. This is more reliable as some browsers will always return
	// "text" as the type if the type attribute is not recognized/supported.
	// If the type attribute is missing, fallback to using what the browser
	// thinks the type is (which is probably "text").
	inputType := InputType(el.GetAttribute("type"))
	if inputType == "" {
		inputType = InputType(el.Type)
	}
	return &Input{
		El:       el,
		Name:     el.Name,
		RawValue: el.Value,
		Type:     inputType,
	}
}
Ejemplo n.º 3
0
func enabler(c, r *dom.HTMLInputElement) {
	c.AddEventListener("click", false, func(dom.Event) {
		r.Disabled = !c.Checked
	})
}