1 pièce(s) jointe(s)
Mise en place évenement dbclick
bonjour tout le monde , je suis débutante en jQuery , et j'ai un petit problème;
je suis entrain de réaliser un arbre qui contient mes nœuds voila l'image :
Pièce jointe 295818
les bouton en haut marche très bien , normalement je doit sélectionner un nœud et après je doit cliquer sur le bouton éditer pour l’éditer,
mais je veut aussi faire l’édition a partir de double click sur l’élément .
alors voila mon code qui fais l’édition a partir du bouton en haut :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| // editable
if (options.editable) {
$(easyTree).find('.easy-tree-toolbar').append('<div class="edit"><button class="btn btn-default btn-sm btn-primary disabled"><span class="glyphicon glyphicon-edit"></span></button></div> ');
$(easyTree).find('.easy-tree-toolbar .edit > button').attr('title', options.i18n.editTip).click(function () {
$(easyTree).find('input.easy-tree-editor').remove();
$(easyTree).find('li > span > a:hidden').show();
var selected = getSelectedItems();
if (selected.length <= 0) {
$(easyTree).prepend(warningAlert);
$(easyTree).find('.alert .alert-content').html(options.i18n.editNull);
}
else if (selected.length > 1) {
$(easyTree).prepend(warningAlert);
$(easyTree).find('.alert .alert-content').html(options.i18n.editMultiple);
}
else {
var value = $(selected).find(' > span > a').text();
$(selected).find(' > span > a').hide();
$(selected).find(' > span').append('<input type="text" class="easy-tree-editor">');
var editor = $(selected).find(' > span > input.easy-tree-editor');
$(editor).val(value);
$(editor).focus();
$(editor).keydown(function (e) {
if (e.which == 13) {
if ($(editor).val() !== '') {
$(selected).find(' > span > a').text($(editor).val());
$(editor).remove();
$(selected).find(' > span > a').show();
}
}
});
}
});
} |
alors la question quel morceau de code je doit ajouter pour pouvoir modifier par double click sur l’élément .?
Merci bien d'avance