Permalink
Browse files

shown / hidden events added

  • Loading branch information...
1 parent 0e83f33 commit a3bf66fd1f5145055943d5855a7ab8487bb0553d @vitalets committed Sep 24, 2012
Showing with 38 additions and 0 deletions.
  1. +6 −0 src/js/bootstrap-editable.js
  2. +32 −0 test/api.js
View
6 src/js/bootstrap-editable.js
@@ -206,6 +206,9 @@
//hide popover on external click
$(document).on('click.editable', $.proxy(this.hide, this));
+
+ //trigger 'shown' event
+ this.$element.trigger('shown', this);
}, this));
},
@@ -322,6 +325,9 @@
if (this.settings.enablefocus || this.$element.get(0) !== this.$toggle.get(0)) {
this.$toggle.focus();
}
+
+ //trigger 'hidden' event
+ this.$element.trigger('hidden', this);
},
/**
View
32 test/api.js
@@ -182,6 +182,38 @@ $(function () {
});
+ asyncTest("'shown' / 'hidden' events", function () {
+ expect(3);
+ var val = '1',
+ e = $('<a href="#" data-pk="1" data-type="select" data-url="post.php" data-name="text1" data-value="'+val+'"></a>').appendTo(fx);
+
+ e.on('shown', function(event, editable) {
+ var p = $(this).data('popover').$tip;
+ ok(p.is(':visible'), 'popover shown');
+ equal(editable.value, val, 'show triggered, value correct');
+ });
+
+ e.on('hidden', function(event, editable) {
+ var p = $(this).data('popover').$tip;
+ ok(!p.is(':visible'), 'popover hidden');
+ });
+
+ e.editable({
+ source: 'groups.php',
+ });
+
+ e.click();
+
+ setTimeout(function() {
+ var p = e.data('popover').$tip;
+ p.find('button[type=button]').click();
+
+ e.remove();
+ start();
+ }, timeout);
+
+ });
+
test("show / hide methods", function () {
var e = $('<a href="#" data-pk="1" data-url="post.php" data-name="text1">abc</a>').appendTo('#qunit-fixture').editable();
e.editable('show');

0 comments on commit a3bf66f

Please sign in to comment.