jQuery - Trigger() once every click - jquery-ui

I've ran into a problem with something quite simple. When I click #mybutton I want to trigger a click on another button.
$('#mybutton').click(function(){
$('#otherbutton').trigger('click');
});
When I first click #mybutton the #otherbutton will trigger once. When I click #mybutton the second time the #otherbutton will trigger twice. When I click #mybutton the third time the #otherbutton will trigger three times...and so on.
How can I stop this so that #otherbutton will only trigger once for each click of #mybutton?
EDIT
Aha! I've just realised this is due to fancybox (where the buttons live).
The buttons are clicked from fancybox popop, which is also triggered to open every time before the buttons are clicked.
$('#planApp-link').fancybox().trigger('click');
I'm still not sure how to prevent this from happenning.

instead of using trigger("click") u can use
$('#otherbutton').click();
this function it ll trigger the click function
$(".clas1").on("click",function(){
$(".clas2").click();
});
$(".clas2").on("click",function(){
alert("div2");
});
.

Related

Ranorex: button.Click() does not work as expected

I'm using Ranorex (v10.1.6) for a Desktop Application written mostly in C#. On a Form there is a table with rows and cells. When clicking on a date cell, it should reveal a button to open the calendar. Therefore I require first a click on the table cell which should make the calendar button visible, after which I then can click the calendar button.
Problem: The click() event does not make the button visible. It seems that the click event does for a fraction of a second make the calendar button visible, but then it disappears again.
It seems that the click event does after the click something different which hides the calendar button again. I also tried to accomplish the same with the Mouse Click, and Mouse.ButtonDown(System.Windows.Forms.MouseButtons.Left) followed by Mouse.ButtonUp(System.Windows.Forms.MouseButtons.Left), but this didn't work either.
Anything else I could try to get this to work?

Vaadin flow grid prevent itemClickListener() to fire on click on buttons in ComponentColumns

With vaadin 23.1.x you can set a itemClickHandler when a user click on a item/row in the grid with myGrid.addItemClickListener(..)
This works fine.
But if you have a component column, with a button in it, then the ClickEvent of the Button is fired and also the itemClickListener of the grid row.
Is there a way to prevent the button click from also triggering the itemClickListener?
You must use this method to add the listener them you can
myGrid.getElement().addEventListener("item-click",
event -> ...)
.addEventData("event.stopPropagation()");
I'm not 100% sure if the even is item-click or just click.

Dropdown click causes focus to next control

I have form with many textbox and select tags. When i click the select tag its not opening the dropdown menu instead it move focus to next control that i have not selected.
This issue occurs only in iPhone.
Please anyone help me to solve this.one.
To Stop automatically closing dropdown issue or stop switching to other element issue use
preventDefault() method in touch event of the select element.
Example
$("#dropDownID").on('touchstart', function (e) {
e.preventDefault();
});

primefaces notificationbar autohide

I have a notificationBar and a commandButton to show it. It works fine, but I need the notificationBar hide itself without the need to click a commandButton to hide it.
Is this possible?
Thanks.
Generally what you have to do to close the notificationbar is the following is to call notificationWidget.hide() when you specified widgetVar="notificationWidget" as a attribute of the notificationbar.
If you would like to have a cross inside the bar to close it, you have to put a commandButton or just a button inside the notificationbar and which calls notificationWidget.hide() on click.
To close the notificationbar after some fixed time you have to register a timer when the notificationbar shows. I.e. setTimeout(notificationWidget.hide, 3000) to close it after 3 seconds.
If you know more exactly what you want to do give some more information or some code, so that i can give you some more concrete answer.

mouseUp firing after button click in mobile Safari (iOS simulator)

I'm trying to build an editing view for a mobile app powered by Backbone.js and Trigger.io. The user goes to a note view and makes changes by tapping "edit" in the top right. When the "edit" button is tapped, we focus on the textarea containing the content and the "edit" button goes away and a "save" button appears. Whenever "edit" is tapped, however, a mouseUp event is firing which results in the textarea losing focus.
The mouseUp event does not fire if the edit button gets hidden and nothing replaces it. The mouseUp does fire if the edit button either A) remains or B) is hidden and save button replaces it.
The only way I've found to fix it is by setting a 200ms+ timeout between hiding the "edit" button and displaying the "save" button.
Is there something with mouseup events firing after click events and/or having them target separate elements? I'd post code but it's all over the place and would not provide much context. If you really need the code, I can post it in parts.
I believe iOs places a delay on the mouseup, to determine if a long touch is being performed. This might help:
http://cubiq.org/remove-onclick-delay-on-webkit-for-iphone

Resources