hx.component($0)
to retrieve the object backing that element (if there is one) <div id="my-tag-input"></div>
<button class="hx-btn" id="my-button">Get Tags</button>
new hx.TagInput('#my-tag-input')
hx.select('#my-button').on('click', function(){
var tagInput = hx.component('#my-tag-input')
hx.notify.info('Tags: ' + tagInput.items().join(', '))
})
<form id="form">
<input name="firstname" placeholder="Firstname" type="text">
<input name="surname" placeholder="Surname" type="text">
<button class="hx-btn hx-action" id="click-button" type="button">Submit</button>
</form>
var element = hx.select('#form')
var api = {
data: function () {
return element.selectAll('input').map(function (sel) {
return sel.attr('name') + ': ' + sel.value()
})
}
}
// Register the component against the element
hx.component.register(element.node(), api)
// Call into the component api to get the value
hx.select('#click-button').on('click', function () {
data = element.component().data()
hx.notify.info(data[0])
hx.notify.info(data[1])
})
Selection::api
api Selection::api
api