Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. $('.chosen-select').chosen({}).change(function (obj, result) {
  2. console.debug("changed: %o", arguments);
  3. console.log("selected: " + result.selected);
  4. });
  5. (function () {
  6. // hold onto the drop down menu
  7. var dropdownMenu;
  8. // and when you show it, move it to the body
  9. $(window).on('chosen:showing_dropdown', function (e) {
  10. // grab the menu
  11. dropdownMenu = $(e.target).next('.chosen-container').find('.chosen-drop');
  12.  
  13. // detach it and append it to the body
  14. $('body').append(dropdownMenu.detach());
  15.  
  16. // grab the new offset position
  17. var eOffset = $(e.target).offset();
  18.  
  19. // make sure to place it where it would normally go (this could be improved)
  20. dropdownMenu.css({
  21. 'top': eOffset.top + $(e.target).outerHeight(),
  22. 'left': eOffset.left
  23. });
  24. });
  25.  
  26. // and when you hide it, reattach the drop down, and hide it normally
  27. $(window).on('chosen:hiding_dropdown', function (e) {
  28. $(e.target).next('.chosen-container').append(dropdownMenu.detach());
  29. });
  30.  
  31. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement