Please Log-in or Register to get full access to the forums.


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] close by left clicking outside tip
29th December, 10:04
Post: #1
[Solved] close by left clicking outside tip
So, I am making a right click menu with qtip2 and I want it to be hidden when you click anywhere outside the tip itself. I assume this needs to be done with the api and a special function but I cant really figure out the best way of doing it. Some help please? =)
Find all posts by this user
Quote this message in a reply
29th December, 17:48
Post: #2
RE: close by left clicking outside tip
Xtracted, sounds like you need a combination of right-click detection (http://craigsworks.com/projects/qtip2/tu...ightclick) and the unfocus event:
JS Code
$('.selector').qtip({
   content: $('#contextMenu'), // Use a pre-formatted element for the content
   position: {
      target: 'mouse', // Position it where the click was...
      adjust: { mouse: false } // ...but don't follow the mouse
   },
   show: 'mousedown', // Can't use click event for this, sorry!
   hide: 'unfocus',
   events: {
      show: function(api, event) {
         /* 
            event.originalEvent contains the event that caused the callback to be fired.
            event.originalEvent.button tells us which button was clicked e.g. 1= left, 2 = right;
         */
         return event.originalEvent.button === 2;
      }
   }
})
// Little snippet that stops the regular right-click menu from appearing
.bind('contextmenu', function(){ return false; });
Visit this user's website Find all posts by this user
Quote this message in a reply
30th December, 08:41 (This post was last modified: 30th December 08:42 by Xtracted.)
Post: #3
RE: close by left clicking outside tip
Perfect, the hide.unfocus was just what I was looking for! Thank you!

I am using the following to prevent the right click menu from appearing:
JS Code
}).bind("contextmenu", function (e) {
                e.preventDefault();
            });


Any comments on using that vs your:

JS Code
.bind('contextmenu', function(){ return false; });


(Except that your code is much prettier=) ?
Find all posts by this user
Quote this message in a reply
30th December, 19:39
Post: #4
RE: [Solved] close by left clicking outside tip
Well return false; actually calls preventDefault(); Check-out this article for more information: http://fuelyourcoding.com/jquery-events-...urn-false/
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] how can i create custom close button? bondrayoon 7 387 25th August 09:28
Last Post: qemmoracuq
  [Solved] Tweak close button style on QTip usingqtip 5 3,868 1st April 11:22
Last Post: Craig
  [Solved] Kill Youtube Video on close in Chrome Wanahackaloogie 1 332 6th March 12:53
Last Post: Wanahackaloogie
  [Solved] Styling close button and <div> vs <a> ? bg17aw 14 1,243 29th November 13:53
Last Post: Craig
  [Solved] Detect click on "close" button gliczynski 3 662 7th October 13:22
Last Post: Craig
  [Solved] Destroy qTip upon clicking X MonkeyZeus 3 610 2nd August 12:57
Last Post: MonkeyZeus
  [Solved] Cannot close a qtip using the keyboard Jesse Pelton 4 944 31st May 18:16
Last Post: Jesse Pelton
  [Solved] Customized Close Button Sidekick_John 3 726 25th March 08:49
Last Post: Sidekick_John
  [Solved] Qtip Close functionality indu 1 618 19th March 14:35
Last Post: Craig
  [Solved] Replace close button with image phpmysqlguy 3 1,013 13th January 06:20
Last Post: phpmysqlguy



User(s) browsing this thread: 1 Guest(s)