I just don't know how to make mouseenter event on trigger on certain element and to perform an action on the other. Here is the thing, i'm trying to make an dropdown menu but not in an ordinary way (submenu nested in an li of the main menu) but to make submenu appears bellow main menu when mouse enters zone of a certain element and submenu should hide when mouse leaves area of submenu. Mouseenter just does not trigger when mouse enters zone of desired element of the main menu. (I tried with console.log but the event just isn't triggering) It's really annoying because mouseleave normally triggers when I deleted initial property display: none, to display submenu initially and when I left area of submenu event worked properly and submenu hid. Does anybody know what the solution is? Function that generates code, annoying events and HTML:     function showMenu(menuJsonData){     var writingMenu = &quot;&quot;;     var writingSubmenu = &quot;&quot;;     for (partOfMenu in menuJsonData){         if(menuJsonData[partOfMenu].primaryHref!=&quot;#&quot;){             writingMenu+=`&lt;li&gt;                             &lt;a href=&quot;${menuJsonData[partOfMenu].primaryHref}&quot; class=&quot;whiteColor linkMarginLeftRight&quot;&gt;${menuJsonData[partOfMenu].primaryLabel}&lt;/a&gt;                         &lt;/li&gt;`;         }         else {             writingMenu+=`&lt;li id=&quot;includesSubmenu&quot;&gt;                             &lt;a href=&quot;${menuJsonData[partOfMenu].primaryHref}&quot; class=&quot;whiteColor linkMarginLeftRight&quot;&gt;${menuJsonData[partOfMenu].primaryLabel}&lt;span class=&quot;fa fa-chevron-down&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;                             &lt;/a&gt;                         &lt;/li&gt;`;             for (partOfSubmenu in menuJsonData[partOfMenu].secondaryHrefs){                                     writingSubmenu+=`&lt;li&gt;                                                      &lt;a href=&quot;${menuJsonData[partOfMenu].secondaryHrefs[partOfSubmenu]}&quot; class=&quot;whiteColor linkMarginLeftRight&quot;&gt;${menuJsonData[partOfMenu].secondaryLabels[partOfSubmenu]}&lt;/a&gt;                                                  &lt;/li&gt;`;             }             document.querySelector(&quot;#submenu&quot;).innerHTML=writingSubmenu;         }     }     document.querySelector(&quot;#menu&quot;).innerHTML=writingMenu; }  $(&quot;#includesSubmenu a&quot;).mouseenter(function(){     console.log('Clint Eastwood');//event doesn't trigger    $(&quot;#submenu&quot;).parent().parent().removeClass(&quot;displayNone&quot;);  });  $(&quot;#submenu&quot;).mouseleave(function(){ console.log('Al Pacino');// event does trigger      $(&quot;#submenu&quot;).parent().parent().addClass(&quot;displayNone&quot;); }); &lt;header class=&quot;width100 redBackgroundColor positionFixed&quot;&gt;             &lt;div class='wrapper displayFlex justifyContentSpaceBetween marginAuto'&gt;                 &lt;div id='logo'&gt;                     &lt;img src='assets/img/logo.png' alt='Logo of The Greatest Gift'/&gt;                 &lt;/div&gt;                 &lt;nav&gt;                     &lt;ul id=&quot;menu&quot; class='displayFlex justifyContentSpaceBetween menuCenter'&gt;&lt;/ul&gt;                 &lt;/nav&gt;             &lt;/div&gt;             &lt;div class=&quot;width100&quot;&gt;                 &lt;div class=&quot;wrapper marginAuto&quot;&gt;                     &lt;ul id=&quot;submenu&quot; class=&quot;displayFlex justifyContentFlexEnd&quot;&gt;&lt;/ul&gt;                 &lt;/div&gt;             &lt;/div&gt;         &lt;/header&gt;
112
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.  This happens on page ready and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
17304
What are the actions that might destructively interfere with the lightning app's lifecycle? Is a breakpoint\debugger statement one of such?  For example there is a case that I happen to meet regularly after Winter 17 release (everything below is performed with Locker Service on, switching it off is not an option). Assume we have some component with an init event handler and "select" element:  ... &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}"/&gt; &lt;select aura:id="select-element" class="slds-select" onchange="{!c.handleSelect}"&gt;&lt;/select&gt;   And here's an "init" handler:  doInit : function(component, event, helper) {     // do smth     debugger; // this can be a debugger statement or manually put browser's breakpoint }   If we happen to have an open console and we catch this breakpoint (immediately resuming it, or not) - in any time later there's no chance to get access to element:  ... component.find("select-element").getElement;   Same happens with div element's, maybe with others.  With absolutely same component's layout and js-controller\helper etc. but with browser's console closed (hence the breakpoint isn't caught) getElement function is there and some code that depends on it will execute successfully.  EDIT: the DOM element is there already (meaning if I use afterRender or some custom button to get a breakpoint far after the init() was executed), I can see it and interact with it - but the getElement function nevertheless is unreachable at that same moment.
50286
I have a funciton that I am currently using to show a hidden div.a_type  How can I modify this code so that instead of fading in the hidden div, I can add the new div to the DOM   jQuery(function(){   // Add Answer      jQuery(".add_answer").click(function(){       if(count >= "4"){         alert('Only 4 Answers Allowed');         }else{       var count = $(this).attr("alt");       count++;       $(this).parents('div:first').find('.a_type_'+count+'').fadeIn();       $(this).attr("alt", count);     }      });   });     Ok, now that i have this sorted out, i have one more question,  I have another function that removes the inserted div's if a button is clicked. It's not working now that the additional divs are not loaded into the dom on pageload. How can i trigger the function to remove these now?  jQuery(function(){   // Hide Answer  jQuery(".destroy_answer").click(function(){   $(this).parents("div:first").fadeOut(function (){ $(this).remove() });    var count = $(this).parents('div:first').parents('div:first').find('.add_answer').attr("alt");    count--;    $(this).parents('div:first').parents('div:first').find('.add_answer').attr("alt", count);  });    });
99580
I am new to Salesforce development. I made a trigger that creates a new asset record and autofills some of the fields on said record. What I want ultimately would be a button that I can put on the "Products" related list on the opportunity page that does what my trigger does. From what I understand, I can't just call my trigger on the button click, and I have to create a VF page or an Apex class that uses the trigger's logic. Does anyone know how I would go about doing this? Here's my code:  trigger ConvertOpportunitiesToAssets on Opportunity (after update) {      List&lt;Asset&gt; a = new List&lt;Asset&gt;();     OpportunityLineItem oli = new OpportunityLineItem();      for(Opportunity o: Trigger.new)     {                   a.add( new Asset(             PSI_Supplier__c = o.Supplier__c,             PSI_Opportunity__c = oli.Product2Id,             AccountId = o.Accountid,             Name = oli.Product2Id,             Product2Id = oli.Product2Id,             Product_Name__c = oli.Product_Name__c             ));            }     insert a; }   Thanks in advance!  UPDATE So I tried making the trigger into a class and button (thanks sfdcfox!), but now it won't work. Here's what I've got:      global class OpportunityWS{     webservice static void createAsset(Id opportunityId)     {         List&lt;Asset&gt; a = new List&lt;Asset&gt;();         Opportunity o = new Opportunity();         OpportunityLineItem oli = new OpportunityLineItem();          a.add( new Asset(             PSI_Supplier__c = o.Supplier__c,             PSI_Opportunity__c = oli.Product2Id,             AccountId = o.Accountid,             Name = oli.Product2Id,             Product2Id = oli.Product2Id,             Product_Name__c = oli.Product_Name__c             ));                 insert a;      } }  {!RequireScript("/soap/ajax/34.0/connection.js")} {!RequireScript("/soap/ajax/34.0/apex.js")} function success() { var alertString="Success!";  alert(alertString);  } function error() { var alertString="Error!";  alert(alertString);  } sforce.connection.sessionId = "{!$Api.Session_ID}"; sforce.apex.execute("OpportunityWS", "createAsset", { opportunityId: "{!Opportunity.Id}" }, { onSuccess: success, onFailure: error });   I can't tell if it's something wrong with the class or the button. I think it must be the class.  UPDATE(AGAIN) Alright so I followed Doug's advice and tried to use the opportunityId to query the opportunity and opportunityLineItem sobjects, was able to compile without errors. But now I'm getting the error message that I made in the button thrown and the asset isn't being created. Unfortunately, I haven't been able to track down the issue. Here's the OpportunityWS apex class that I've updated since last edit:  global class OpportunityWS{ webservice static void createAsset(Id opportunityId) {     List&lt;Asset&gt; a = new List&lt;Asset&gt;();     List&lt;Opportunity&gt; o = [SELECT Supplier__c, Accountid FROM Opportunity WHERE Id = :opportunityId];     List&lt;OpportunityLineItem&gt; oli = [SELECT Product2Id, Product_Name__c FROM OpportunityLineItem WHERE Id = :opportunityId];      a.add( new Asset(         PSI_Supplier__c = o[0].Supplier__c,         PSI_Opportunity__c = oli[0].Product2Id,         AccountId = o[1].Accountid,         Name = oli[0].Product2Id,         Product2Id = oli[0].Product2Id,         Product_Name__c = oli[1].Product_Name__c         ));             insert a; }   }
109505
I'm programmatically adding ToolStripButton items to a context menu.  That part is easy.  this.tsmiDelete.DropDownItems.Add("The text on the item.");   However, I also need to wire up the events so that when the user clicks the item something actually happens!  How do I do this? The method that handles the click also needs to receive some sort of id or object that relates to the particular ToolStripButton that the user clicked.
61949
Is there a way to select a parent element based on the class of a child element in the class?  The example that is relevant to me relating to HTML output by a nice menu plugin for .  The output renders like this:    &lt;ul class="menu"&gt;       &lt;li&gt;           &lt;a class="active"&gt;Active Page&lt;/a&gt;       &lt;/li&gt;       &lt;li&gt;             &lt;a&gt;Some Other Page&lt;/a&gt;       &lt;/li&gt;   &lt;/ul&gt;     My question is whether or not it is possible to apply a style to the list item that contains the anchor with the active class on it.  Obviously, I'd prefer that the list item be marked as active, but I don't have control of the code that gets produced.  I could perform this sort of thing using javascript (JQuery springs to mind), but I was wondering if there is a way to do this using CSS selectors.  Just to be clear, I want to apply a style to the list item, not the anchor.
14725
I have a few images and their rollover images. Using jQuery, I want to show/hide the rollover image when the onmousemove/onmouseout event happen. All my image names follow the same pattern, like this:  Original Image: Image.gif Rollover Image: Imageover.gif  I want to insert and remove the &quot;over&quot; portion of image source in the onmouseover and onmouseout event, respectively. How can I do it using jQuery?
106496
When I use the MouseUp event, I can get it to fire with a mouse right-click. But MouseLeftButtonUp won't fire with either click!  &lt;Button MouseLeftButtonUp="btnNewConfig_MouseUp"  Name="btnNewConfig"&gt;     &lt;StackPanel Orientation="Horizontal"&gt;         &lt;Image Source="Icons\new.ico" Height="24" Width="24" Margin="5"/&gt;         &lt;TextBlock VerticalAlignment="Center"&gt;New&lt;/TextBlock&gt;     &lt;/StackPanel&gt; &lt;/Button&gt;   I know this is most likely something simple. Thanks for the help!
70627
Im on a lightning community, i have a lightning component and i want to open another component with this code:  navigateToMyComponent : function(component, event, helper) {     console.log('1');     var evt = $A.get("e.force:navigateToComponent");     console.log('2');     evt.setParams({         componentDef : "c:CompetenciaComponent"     });     console.log('3');     evt.fire();     console.log('4'); }   this its the console log:   NOTHINGS HAPPEND AND I DONT KNOW WHY
71962
I have an element with an onclick method.  I would like to activate that method (or: fake a click on this element) within another function.  Is this possible?
113588
I'm trying to get an event to fire whenever a choice is made from a JComboBox.  The problem I'm having is that there is no obvious addSelectionListener() method.  I've tried to use actionPerformed(), but it never fires.  Short of overriding the model for the JComboBox, I'm out of ideas.  How do I get notified of a selection change on a JComboBox?**  Edit: I have to apologize. It turns out I was using a misbehaving subclass of JComboBox, but I'll leave the question up since your answer is good.
12181
Is there a best-practice or common way in JavaScript to have class members as event handlers?  Consider the following simple example:  &lt;head&gt;     &lt;script language="javascript" type="text/javascript"&gt;          ClickCounter = function(buttonId) {             this._clickCount = 0;             document.getElementById(buttonId).onclick = this.buttonClicked;         }          ClickCounter.prototype = {             buttonClicked: function() {                 this._clickCount++;                 alert('the button was clicked ' + this._clickCount + ' times');             }         }      &lt;/script&gt; &lt;/head&gt; &lt;body&gt;     &lt;input type="button" id="btn1" value="Click me" /&gt;     &lt;script language="javascript" type="text/javascript"&gt;         var btn1counter = new ClickCounter('btn1');     &lt;/script&gt; &lt;/body&gt;   The event handler buttonClicked gets called, but the _clickCount member is inaccessible, or this points to some other object.  Any good tips/articles/resources about this kind of problems?
64167
I need to debug a web application that uses jQuery to do some fairly complex and messy  manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working.  If I had a capability to edit the application source, I would drill down and add a bunch of  console.log() statements and comment/uncomment pieces of code to try to pinpoint the problem. But let's assume I cannot edit the application code and need to work entirely in Firefox using Firebug or similar tools.  Firebug is very good at letting me navigate and manipulate the DOM. So far, though, I have not been able to figure out how to do event debugging with Firebug. Specifically, I just want to see a list of event handlers bound to a particular element at a given time (using Firebug JavaScript breakpoints to trace the changes). But either Firebug does not have the capability to see bound events, or I'm too dumb to find it. :-)  Any recommendations or ideas? Ideally, I would just like to see and edit events bound to elements, similarly to how I can edit DOM today.
29988
I have a problem with an object I have created that looks something like this:  var myObject = {      AddChildRowEvents: function(row, p2) {         if(document.attachEvent) {             row.attachEvent('onclick', function(){this.DoSomething();});         } else {             row.addEventListener('click', function(){this.DoSomething();}, false);         }     },      DoSomething: function() {         this.SomethingElse(); //&lt;-- Error here, object 'this' does not support this method.     } }   The problem is that when I am inside the 'DoSomething' function, 'this' does not refer to 'myObject' what am I doing wrong?
60344
Imagine I use the .NET graphic classes to draw a rectangle.  How could I then assign an event so that if the user clicks a certain point, or a certain point range, something happens (a click event handler)?  I was reading CLR via C# and the event section, and I thought of this scenario from what I had read.  A code example of this would really improve my understanding of events in C#/.NET.  Thanks
104303
I have a dockable window with a 2 buttons that call 2 different tools (Draw Marker and Select Features), What i want to happen is when the user clicks on the relevant button on the dockable window and then clicks on the map, a onMouseUp event is called and it runs code i need to run.   Where does the onMouseUp event need to be placed so this can be done?
119247
I got a set of meta boxes on a custom post type. Two of them are simple input/text-type fields, that should have autocompleted input:   A) Another Custom Post Type B) Users   Now I have the problem that I need to somehow trigger the autocomplete event. So far I have this pretty simple definition:  jQuery( document ).ready( function ($)         {             $( '#some_id' ).autocomplete(             {                  minLength: 2                 ,source:    "&lt;?php print 'SOME_STRING'; ?&gt;"             } );         } );   which gives me the following answer in the console, when I enter "zz":      GET http:// localhost/wordpress/wp-admin/SOME_STRING?term=zz 404 (Not Found)   Point is that I need to run a query (as you can see above) and need to root the request for the source option/argument from autocomplete somehow to a php callback.  I hope someone can explain me how I'd get around this. Thanks (and merry christmas in case you read this :) !