Sailing_12
asked on
jQuery - Select AND show context menu on textbox right-click
I'm using the script below and the jQuery right-click plugin to modifiy the behavior of all text boxes on a form to select all content upon right-click.
Works OK except that I've lost the default context-menu behavior which I'd like to keep.
Anyone know how to ge this back along with the auto-select?
Works OK except that I've lost the default context-menu behavior which I'd like to keep.
Anyone know how to ge this back along with the auto-select?
$(function() {
$('input[type=text]').rightClick(function(e) {
this.select();
//alert("Got it");
});
});
Not sure what you mean >lost works OK except that I've lost the default context-menu behavior which I'd like to keep.
one thing I would like to point out...to get the current obj reference instead of
this.select();
you should be using:
$(this).select();
this.select();
you should be using:
$(this).select();
ASKER
When you right-click on a standard textbox, a default context menu appears with items like Cut, Copy, Paste, etc. The script I have implemented above seems to prevent this menu from appearing at all.
Ideally, I would like the right-click event to both select the entire content string of the textbox AND trigger the standard context menu to appear so that a user can simply right-click and Paste to replace the entire string, a phone number in this case.
Ideally, I would like the right-click event to both select the entire content string of the textbox AND trigger the standard context menu to appear so that a user can simply right-click and Paste to replace the entire string, a phone number in this case.
ASKER
Since I haven't got much response yet, I'm increasing the points for this question to 500.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK. So would my page script then look like this since we are calling the select action from the plugin instead of the page head?
$(function() {
$('input[type=text]').rightClick(function(e) {});
});
yes...correct
what browser are testing in
ASKER
OK. Seems to work. Thanks.