Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Reflect 'change' events from the underlying element #27

Closed
wants to merge 1 commit into from

3 participants

@marxian

Currently DropKick doesn't reflect programmatic (or other) changes
to the underlying element. Here we introduce a configuration option which sets up a simple binding to the 's 'change' event. The bound function tries
to use DropKick internal methods to reflect the change.

@marxian marxian Support 'reverseSync' option
Currently Dropkick doesn't reflect programmatic (or other) changes
to the underlying <select> element.

Here we introduce a configuration option which sets up a simple
binding to the <select>'s 'change' event. The bound function tries
to use DropKick internal methods to reflect the change.
04fcb1e
@sos4nt

This should be the default. I don't see any reason why Dropkick shouldn't reflect changes to its underlying element.

@Robdel12
Owner

Its broke currently on version 1.1, but I can get it to work. Just know after 2 years it'll make it in :grinning:

@Robdel12 Robdel12 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 13, 2011
  1. @marxian

    Support 'reverseSync' option

    marxian authored
    Currently Dropkick doesn't reflect programmatic (or other) changes
    to the underlying <select> element.
    
    Here we introduce a configuration option which sets up a simple
    binding to the <select>'s 'change' event. The bound function tries
    to use DropKick internal methods to reflect the change.
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 2 deletions.
  1. +12 −2 jquery.dropkick-1.0.0.js
View
14 jquery.dropkick-1.0.0.js
@@ -55,7 +55,9 @@
defaults = {
startSpeed : 1000, // I recommend a high value here, I feel it makes the changes less noticeable to the user
theme : false,
- change : false
+ change : false,
+ reverseSync: false
+
},
// Make sure we only bind keydown on the document once
@@ -146,6 +148,14 @@
$dk.removeClass('dk_open dk_focus');
});
+ // Sync to change events on the original <select> if requested
+ if (data.settings.reverseSync) {
+ $select.bind('change', function(e){
+ var $dkopt = $(':[data-dk-dropdown-value="'+$select.val()+'"]', $dk);
+ _updateFields($dkopt, $dk, true);
+ });
+ }
+
setTimeout(function () {
$select.hide();
}, 0);
@@ -399,4 +409,4 @@
}
});
});
-})(jQuery, window, document);
+})(jQuery, window, document);
Something went wrong with that request. Please try again.