oxjs/examples/forms/editable_elements/js/example.js

54 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2013-02-26 05:14:27 +00:00
/*
This example shows elements that are editable inline — either a span or a
div.
*/
'use strict';
Ox.load('UI', function() {
var $box = Ox.Element()
.attr({id: 'box'})
.appendTo(Ox.$body);
Ox.loop(1, 4, function(i) {
Ox.$('<span>')
.addClass('label')
2013-02-27 07:33:55 +00:00
.html((i > 1 ? '&nbsp;' : '') + 'SPAN #' + i + ':&nbsp;')
2013-02-26 05:14:27 +00:00
.appendTo($box);
Ox.EditableContent({
2013-02-27 07:33:55 +00:00
editing: i == 1,
placeholder: 'Placeholder',
2013-02-26 05:14:27 +00:00
tooltip: 'Doubleclick to edit'
})
2013-02-27 07:33:55 +00:00
.bindEvent({
submit: function(data) {
Ox.print(data.value);
}
})
2013-02-26 05:14:27 +00:00
.appendTo($box);
});
Ox.$('<div>')
.addClass('label')
2013-02-27 07:33:55 +00:00
.html('DIV')
2013-02-26 05:14:27 +00:00
.appendTo($box);
Ox.EditableContent({
2013-02-27 07:33:55 +00:00
placeholder: 'Placeholder',
tooltip: function(e) {
var $target = $(e.target);
return $target.is('a') || $target.parents('a').length
? 'Shift+doubleclick to edit' : 'Doubleclick to edit';
},
type: 'div',
value: 'This is a <a href="http://google.com">link</a>.'
})
.css({width: '512px'})
.bindEvent({
submit: function(data) {
Ox.print(data.value);
}
2013-02-26 05:14:27 +00:00
})
.appendTo($box);
});