I have a country drop down, and on change of it I return a div containing the same country drop down with additional fields.  I replace this entire div using the below code. But after the replace of div is done, the on change event stops working further. How can I fix this ?      $("#country).on("change", function(){         var str = $("#myform").serialize();         $.ajax({             type: 'POST',             data:str,             url:'../changeme',             success: function(data){                  debugger;                  var html = $.parseHTML(data);                 var arrSelector = $(html).find('div[data-refresh=true]');                 var i;                 for(i=0;i&lt;arrSelector.length;i++)                 {                      $('#' + arrSelector[i].id).replaceWith($($(data)).find('#' + arrSelector[i].id));                 }             },             done:function(data){              },             error:function(data){              },             complete:function(data){              }         });     }); },
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.
90856
Ok, I'm doing a bunch of RIA/AJAX stuff and need to create a "pretty", custom confirm box which is a DIV (not the built-in javascript confirm). I'm having trouble determining how to accomplish a pause in execution to give the user a chance to accept or decline the condition before either resuming or halting execution. (depending upon their answer)   So here's the general flow of logic I'm dealing with:   User selects an item from dropdown and clicks button. In client-side javascript eventhandler for button, I need to check a (this is the key) SERIES of conditions for the item they chose in dropdown.  These conditions could possibly result in not showing any confirmation at all or possibly only some of the conditions may evaluate to true which means I'll need to ask the user to accept or decline the condition before proceeding. Only one confirmation should be show at a time.   To demonstrate the logic:  function buttonEventHandler() {  if (condition1) {   if(!showConfirmForCondition1) // want execution to pause while waiting for user response.      return; // discontinue execution }  if (condition2) {   if (!showConfirmForCondition2) // want execution to pause while waiting for user response.       return; // discontinue execution }  if (condition3) {   if (!showConfirmForCondition3) // want execution to pause while waiting for user response.       return; // discontinue execution }  ...   }    If anybody has dealt with this challenge before and found a solution, help would be greatly appreciated. As a note, I'm also using the MS Ajax and jQuery libraries although I haven't found any functionality that may already be included in those for this problem.
95782
So I did some reading of the related questions and had some interesting stuff but did not find my answer, at least did not understand the answer.  I am very new to AJAX, javascript and sclient side scripting in general.  I have been using C# asp.net for a bit and recently added some updatepanels to my side to smooth so of the user controls and bits being updated so that the page was not reloaded each time.  All works brilliantly and I was very happy with it till I decided to try and use some JQuery.  I have picked up the datepicker from ui.jquery.js which is cool and works great on a normal page.  My problem arrives when I do a postback from within an updatepanel.  The datepicker just stops working.  from what I have read I need to manually wire this back up after the post back.  1)  I don't really understand why.  on my master page I have:  &lt;script type="text/javascript"&gt;     $(function() {         $(".mydatepickerclass").datepicker({dateFormat: 'dd-mm-yy'});     }); &lt;/script&gt;   which picks up my input boxes with the mydatepickerclass assigned. and all works.  Why would this stop working on the postback.  2)  How do I fix this.... how do I wire it up so that after a postback in an updatepanel it still works.  I understand that the ID might change on a postback, I think but as I am using classes I don't know what is going wrong.  edit  I have the following code in my usercontrol where the update is happening:  &lt;asp:UpdatePanel ID="HistoryUpdatePanel" runat="server"&gt; &lt;ContentTemplate&gt;     &lt;%-- Start of Company History section --%&gt;     &lt;fieldset&gt;         &lt;legend&gt;Activity History&lt;/legend&gt;             &lt;script type="text/javascript"&gt;               $(function() {               $(".mydatepickerclass").datepicker({dateFormat: 'dd-mm-yy'});               });            &lt;/script&gt;                      &lt;div&gt;             &lt;asp:ListBox ID="listBoxHistoryTypes" runat="server" SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="listBoxHistoryTypes_IndexChanged" /&gt;             &lt;label&gt;Date From:&lt;/label&gt;&lt;asp:TextBox class="mydatepickerclass" ID="txtdatefrom" runat="server" /&gt;             &lt;label&gt;Date To:&lt;/label&gt;&lt;input class="mydatepickerclass" type="text" /&gt;             &lt;asp:TextBox class="mydatepickerclass" ID="txtdateto" runat="server" /&gt;             &lt;asp:Button ID="btnFilterSearch" runat="server" Text="Filter Results" OnClick="btnFilterSearch_Click" /&gt;         &lt;/div&gt;       &lt;/fieldset&gt; &lt;/ContentTemplate&gt;     Does the script inside the updatepanel not rewire it?  Thanks  Jon Hawkins
60861
I have an AJAX button that should update form fields according to data already provided by user:   'ajax_button' =&gt; array(     '#type' =&gt; 'button',     '#value' =&gt; t("Scan for tags"),     '#ajax' =&gt; array(       'callback' =&gt; 'ajax_tag',       'wrapper' =&gt; 'dynamic-tags-fieldset',       'method' =&gt; 'replace',       'event' =&gt; 'click',       'prevent' =&gt; 'submit click mousedown',     ),   ),   It works, but only if form is valid. Of course I do not want to validate it just yet. I don't care if all fields are filled, I only need my form to be updated at this very moment. How can I make form api not to invoke hook_form_validate() and not test #required fields?
59846
In the following example code, I attach an onclick event handler to the span containing the text "foo". The handler is an anonymous function that pops up an alert().  However, if I assign to the parent node's innerHTML, this onclick event handler gets destroyed - clicking "foo" fails to pop up the alert box.  Is this fixable?  &lt;html&gt;  &lt;head&gt;  &lt;script type="text/javascript"&gt;    function start () {     myspan = document.getElementById("myspan");     myspan.onclick = function() { alert ("hi"); };      mydiv = document.getElementById("mydiv");     mydiv.innerHTML += "bar";   }   &lt;/script&gt;  &lt;/head&gt;   &lt;body onload="start()"&gt;    &lt;div id="mydiv" style="border: solid red 2px"&gt;      &lt;span id="myspan"&gt;foo&lt;/span&gt;    &lt;/div&gt;  &lt;/body&gt;  &lt;/html&gt;
108198
We have updated the jQuery version that Stack Overflow and Stack Exchange use from version 1.7.1 to 1.12.4 today (Tuesday, September 27, 2016). jQuery is an infrastructure library, and we've been running on an old version for a while because it worked well. However, there are a few improvements and features that made it compelling for us to upgrade, especially since some parts of the site already used a different version.  As a user of our Q&amp;A sites, nothing should visibly change, as this is an infrastructure rather than a feature update. However, with an infrastructure update like this, there is always a chance for things to slip through the cracks.     If you encounter functionality that used to work yesterday and is broken today, please leave an answer on this thread and accept my apologies in advance.   Please be aware of our .  Do note that userscripts that rely on  (like .live() - anything in the 1.7, 1.8, 1.9 and 1.10 category, and if you can in the 3.0 as well to make a future update less likely to break your script) may need to be updated. There were no DOM or other structural changes, so selectors should still be the same.  If you're curious why we're going to jQuery 1.12.4 and not 3.1, this is a matter of incrementally upgrading and making sure things work along the way. Pretty much every 1.x version had major changes, and jQuery recommends upgrading an old 1.x version to the latest 1.12.4 and  plugin first and fix anything that is deprecated. We are in this stage now and want to make sure everything still works.
115970
Using a ajax request I want to change content of my div.  &lt;div id="d1"&gt;202&lt;/div&gt;   So I want to change the content to a different number.  $('d1').InnerText???   Also, say I wanted to increment the number, how could I do that? Do I have to convert to int?
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.
4228
As the question says, how do I add a new option to a DropDownList using jQuery?  Thanks
80540
I'm trying to do some treatement after creating an item but the treatement is done twice because in my code after creating the item, I'm updating it , so the event reciever get fired twice: first when I add the element and the second when I updated it. Here's the code :  if (Mode == OperationMode.New) {     item = ListeActions.AddItem();     item["Client"] = new SPFieldLookupValue(myClient.ID, myClient["Name"] as string).ToString();     //the Event Reciever ItemAdded is fired here } if (Mode == OperationMode.Edit) {     item = ListeActions.GetItemById(ActionItemID); } TextField ACObject = (TextField)Page.GetControlById("ACObjectID"); UserField ACAssignedTo = (UserField)Page.GetControlById("ACAssignedToID"); NoteField ACDetails = (NoteField)Page.GetControlById("ACDetailsID");  item["Object"] = ACObject.Value; item["AssignedTo"] = ACAssignedTo.Value; item["Details"] = ACDetails.Value;  item.Update();  //if we're in the case of adding new item then the event //reciever ItemAdded is fired here for the second time //while ItemUpdated is not fired   So how can I stop the second fire of itemAdded resulting on the item.Update() yet keep the first fire since I need to keep applying my treatement?  PS: in the case of updating an existing ListeActions.item the itemUpdated is fired twice too !!  BTW : This Code isn't written in the itemadded method nor in the itemupdated method, actually it's the code in a user control for a webpart development.
108830
I've got a div that contains some content that's being added and removed dynamically, so its height is changing often. I also have a div that is absolutely positioned directly underneath with javascript, so unless I can detect when the height of the div changes, I can't reposition the div below it.  So, how can I detect when the height of that div changes? I assume there's some jQuery event I need to use, but I'm not sure which one to hook into.
116321
&lt;template&gt;            &lt;lightning-card&gt;                     &lt;lightning-input type=&quot;text&quot; label=&quot;field1&quot; name=&quot;field1&quot; onchange={handleChange}&gt;&lt;/lightning-input&gt;                     &lt;lightning-input type=&quot;text&quot; label=&quot;field2&quot; name=&quot;field2&quot; onchange={handleChange}&gt;&lt;/lightning-input&gt;                     &lt;lightning-input type=&quot;text&quot; label=&quot;field3&quot; name=&quot;field3&quot; onchange={handleChange}&gt;&lt;/lightning-input&gt;                     &lt;div if:true={errorMsg} style=&quot;margin-left: 0%;&quot;&gt;                         &lt;p style=&quot;color: red;&quot;&gt;{errorMsg}&lt;/p&gt;                     &lt;/div&gt;                 &lt;/lightning-card&gt;         &lt;div style=&quot;float: right&quot; class=&quot;slds-p-bottom--large&quot;&gt;         &lt;lightning-button class=&quot;slds-m-left_x-small&quot; label=&quot;Previous&quot; onclick={handlePrevious}&gt;         &lt;/lightning-button&gt;         &lt;lightning-button class=&quot;slds-m-left_x-small&quot; label=&quot;Next&quot; variant=&quot;brand&quot; onclick={handleNext}&gt;         &lt;/lightning-button&gt;     &lt;/div&gt; &lt;/template&gt;  We have above lwc component, which is embedded in screenflow. and the screen flow previous,next buttons are overrided by using Flow Navigation Events. So when we clicked on Previous button, we are facing  class java.lang.String cannot be cast to class java.lang.Boolean (java.lang.String and java.lang.Boolean are in module java.base of loader 'bootstrap')
72487
I have an HTML element with a large collection of unordered lists contained within it. I need to clone this element to place elsewhere on the page with different styles added (this is simple enough using jQuery).    $("#MainConfig").clone(false).appendTo($("#smallConfig"));   The problem, however, is that all the lists and their associated list items have IDs and clone duplicates them. Is there an easy way to replace all these duplicate IDs using jQuery before appending?
107747
Please bear with me because I am new to utilizing Wordpress PHP this way. I have the following script:  &lt;div id="content"&gt; &lt;?php     // check if the repeater field has rows of data     if( have_rows('repeat_field') ):         $i = 0;          // loop through the rows of data         while ( have_rows('repeat_field') ) : the_row();             $i++;              // display a sub field value             if (!empty(get_sub_field('feature_image_post'))) {                  echo '&lt;a href="';                 the_sub_field('restaurant_article_link');                  echo '"&gt;';             }              if( $i &gt;= 78 ) {                 break;             }                     endwhile;     else :         // no rows found     endif;     ?&gt;     &lt;/div&gt;     &lt;div id="loading-image" style="display: none;"&gt;&lt;/div&gt;     &lt;div id="part2"&gt;&lt;/div&gt;     &lt;script&gt;          var w = $(window);         window.onscroll = function(ev) {             if ($(document).height() - w.height() == w.scrollTop()) {                  $('#loading-image').show();                 $.ajax({                     url: "&lt;?php echo get_stylesheet_directory_uri();?&gt;/post-2.php",                     cache: false,                     success: function(result){                       $("#part2").html(result);                     },                     complete: function(){                       $('#loading-image').hide();                     }                 });             }         };     &lt;/script&gt;   The the Php page that I am trying to load pretty much contains the same code . It just stops after loading 200 fields.   &lt;?php     // check if the repeater field has rows of data     if( have_rows('repeat_field') ):         $i = 0;         // loop through the rows of data         while ( have_rows('repeat_field') ) : the_row();             $i++;             // display a sub field value             if (!empty(get_sub_field('feature_image_post'))) {                 echo '&lt;a href="';                 the_sub_field('restaurant_article_link');                  echo '"&gt;';             }              if( $i &gt;= 200 ){               break;             }                      endwhile;     else :         // no rows found     endif; ?&gt;   I don't know why the php page (post-2.php) is not loading. The strange thing is that when I replace &lt;?php echo get_stylesheet_directory_uri();?&gt;/post-2.php with a test html page &lt;?php echo get_stylesheet_directory_uri();?&gt;/test.html The test page (test.html) loads.  I have to say that I looked on in my console using the console tab of my browser added console.log(); to view any errors and I'm not getting any errors. I also looked in my networked tag to ensure that post-2.php loaded properly and I'm not getting errors. My goal is to find out why my PHP page isn't loading  ***** Update ***** I'm being told to use $post_id but I've never used it. Does anyone have a working example of this? Would it be similar to if( have_rows('repeat_field', $post_id) ): or if( have_rows('repeat_field', 55612) ): ?
12135
I want to iterate through a dropdown, select the first value, then click search, then again select the second value and again perform search.In this code i have tried selecting only one option,but I want to perform search on all the options one by one
96142
I am working on a requirement to create an opportunity and opportunity products , when there is an update on the asset object.  The asset object has a filed called Refresh_Asset_To__c, this is a lookup to the product object.   Basically each time I change the product on the Refresh_Asset_To__c, a new opportunity should be generated with the Refresh_Asset_To__c being the opportunity product.  I have tested , and its generating the opportunity , but each time i try to insert the opportunity product I get the error :      Update failed. First exception on row 0 with id 02i3B000003TAk7QAG; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssetRefreshOpp: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry currency code does not match opportunity currency code): [PricebookEntryId] Trigger.AssetRefreshOpp: line 56, column 1: []   This is my code:  trigger AssetRefreshOpp on Asset (after update) {      Pricebook2 ikmBook    = [SELECT Id,CurrencyIsoCode FROM Pricebook2 WHERE Id = '01s46000003K1zXAAS'];  List&lt;OpportunityLineItem&gt; oppLiList = new List&lt;OpportunityLineItem&gt;(); Opportunity opp; OpportunityLineItem oli; string refeshed;     List&lt;asset&gt; refreshedAss = [select Id,Contract__r.EndDate,OwnerId,quantity,Name,Refresh_Asset_To__c,Refresh_Asset_To__r.Id,AccountId,account.name from asset                                      where Id IN : Trigger.new                                      And Refresh_Asset__c = True];          for(asset myAss:refreshedAss){             // Create New Opportunity              Opportunity newopp =new Opportunity();   newopp.Name=myAss.account.name + ' ' + 'refreshed'; newOpp.AccountId = myAss.AccountId; newOpp.CloseDate = myAss.Contract__r.EndDate; newOpp.StageName = 'Create'; newOpp.RecordTypeID = '01246000000TfMZAA0'; newOpp.OwnerId = myAss.OwnerId; newOpp.Amount = 0; newOpp.Type= 'Existing Business'; newOpp.OM_Order_Type__c = 'Regular'; newOpp.CurrencyIsoCode = ikmBook.CurrencyIsoCode; newOpp.Pricebook2Id = ikmBook.Id;  insert newOpp;          List&lt;PriceBookEntry&gt; priceBookList = [SELECT Id, Product2Id,CurrencyIsoCode, Product2.Id, Product2.Name FROM PriceBookEntry WHERE  PriceBook2.isStandard=true LIMIT 1];               for(asset myAssets:refreshedAss){               OpportunityLineItem oli = new OpportunityLineItem();                oli.OpportunityId = newOpp.Id;                oli.Product2Id = myAssets.Refresh_Asset_To__r.Id;                oli.PriceBookEntryId = priceBookList[0].Id;                oli.UnitPrice = 0;               oli.Quantity = myAssets.Quantity;               oppLiList.add(oli);           }           insert oppLiList;               } }
87646
Salesforce has functions that do a lot of basic web app functionality for you, called Event Reference. They can be found here   On the editRecord Event Reference, found here   essentaily, I create a   &lt;ui:button label="Edit" press="{!c.editRecord}"/&gt;   on my component, reference the attribute on the page and add the function from the docs in the controller  editRecord : function(component, event, helper) {     var editRecordEvent = $A.get("e.force:editRecord");      console.log("record id is: " + component.get("v.item.Id"));     console.log("editRecordEvent value is: " + editRecordEvent);      editRecordEvent.setParams({         "recordId": component.get("v.item.Id")     });      editRecordEvent.fire(); }   correct?  Here is the odd thing. From the console.logs, I get the record id, but the editRecordEvent returns undefined. What is going on? Is there something I need to reference in my component to use Event Reference?