I have a issue with click event. I am using jPList plugin and I have a click function for each result set. The first page click function is working correctly, but when I select second or third page and click the button it doesn't get fired.   HTML  &lt;!-- demo --&gt; &lt;div id="demo"&gt;  &lt;!-- panel --&gt; &lt;div class="jplist-panel"&gt;  &lt;!-- pagination control --&gt; &lt;div class="jplist-pagination" data-control-type="pagination" data-control-name="paging" data-control-action="paging" data-items-per-page="2"&gt; &lt;/div&gt;  &lt;/div&gt;  &lt;!-- HTML data --&gt; &lt;div class="list"&gt;  &lt;!-- item 1 --&gt; &lt;div class="list-item"&gt;   &lt;p&gt;     first result   &lt;/p&gt;   &lt;p class="hitme"&gt;     click me   &lt;/p&gt;   &lt;hr&gt; &lt;/div&gt;  &lt;!-- item 2 --&gt; &lt;div class="list-item"&gt;   &lt;p&gt;     second result   &lt;/p&gt;   &lt;hr&gt; &lt;/div&gt;  &lt;!-- item 3 --&gt; &lt;div class="list-item"&gt;   &lt;p&gt;     thrid result   &lt;/p&gt;   &lt;button class="hitme"&gt;     click me   &lt;/button&gt;   &lt;hr&gt; &lt;/div&gt;  &lt;!-- item 4 --&gt; &lt;div class="list-item"&gt;   &lt;p&gt;     fourth result   &lt;/p&gt;   &lt;hr&gt;  &lt;/div&gt;  &lt;hr&gt;   &lt;!-- item 5 --&gt;  &lt;div class="list-item"&gt;   &lt;p&gt;     fifth result   &lt;/p&gt;   &lt;button class="hitme"&gt;     click me   &lt;/button&gt;   &lt;hr&gt;   &lt;/div&gt;   &lt;!-- item 6 --&gt;  &lt;div class="list-item"&gt;   &lt;p&gt;     sixth result   &lt;/p&gt;    &lt;/div&gt;  &lt;/div&gt;  &lt;/div&gt;   jQuery  $('document').ready(function() {  $('#demo').jplist({ itemsBox: '.list', itemPath: '.list-item', panelPath: '.jplist-panel' });  $('.hitme').on('click', function() {  alert('clicked'); })  });   Can anyone help me with this please.   See the
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.
35807
I have created a VF page and used "render as pdf"  &lt;apex:commandButton value="Save to Opportunity" action="{!savePdf}"  /&gt;   Its working fine when i am using above line without rerender and oncomplete but when i am adding rerender or oncomplete it is not working.I am able to save the PDF in attachment folder but when i am trying to open its showing  "Unable to load document"  Even if i remove oncomplete and use Rerender then also its saving the attachment in Attachment object and when i view ,it is not loading and says "Unable to load document"      &lt;apex:commandButton value="Save to Opportunity" action="{!savePdf}"  oncomplete="myClose();"/&gt;   Javascript Code  function myClose(){      self.close();     window.opener.location.href="/{!$CurrentPage.parameters.Id}";  }   Class Code  public void savePdf() {      PageReference pdf = Page.GenerateQuotePDF;     pdf.getParameters().put('id',parentId);      Attachment attach = new Attachment();      Blob body;     body = pdf.getContent();     attach.Body = body;     attach.Name = 'Opportunity'+ '.pdf';       attach.IsPrivate = false;     attach.ParentId = parentId;     attach.ContentType = 'application/pdf';     insert attach;     }     Please help..
15466
&lt;apex:page standardController="Employee__c" extensions="testPage" id="p"&gt; &lt;apex:form id="f"&gt;        &lt;div&gt;         &lt;input type="radio" name="acc" value="Existing" checked="checked"                 onclick="show(true, false);"&gt;Existing&lt;/input&gt;         &lt;input type="radio" name="acc" value="NEWAcc"                 onclick="show(false, true);"&gt;New&lt;/input&gt;     &lt;/div&gt;     &lt;apex:pageBlock id="pb1" title="Pg Block 1"&gt;     &lt;apex:pageBlockButtons &gt;  &lt;apex:commandButton value="save" action="{!saving}"/&gt;    &lt;/apex:pageBlockButtons&gt;     &lt;apex:pageBlockSection columns="1"&gt;    &lt;apex:inputField value="{!pme.Name}" /&gt;    &lt;apex:inputField value="{!pme.Address__c}"/&gt;       &lt;apex:inputField value="{!pme.Phone__c}"/&gt; &lt;apex:inputField value="{!pme.type__c}"/&gt;     &lt;/apex:pageBlockSection&gt;     &lt;/apex:pageBlock&gt;     &lt;apex:pageBlock id="pb2" title="Pg Block 2"&gt;     &lt;apex:pageBlockButtons &gt;  &lt;apex:commandButton value="save" action="{!saving}"/&gt;   &lt;/apex:pageBlockButtons&gt;     &lt;apex:pageBlockSection columns="1"&gt;    &lt;apex:inputField value="{!pme.Name}" /&gt; &lt;apex:inputField value="{!pme.Job_Title__c}"/&gt;    &lt;apex:inputField value="{!pme.Salary__c}"/&gt;    &lt;apex:inputField value="{!pme.type__c}"/&gt;     &lt;/apex:pageBlockSection&gt;     &lt;/apex:pageBlock&gt; &lt;/apex:form&gt;    &lt;script&gt; function show(showPb1, showPb2) {     // Match Visualforce's prefixing pattern     document.getElementById('p:f:pb1').style.display = showPb1 ? 'block' : 'none';     document.getElementById('p:f:pb2').style.display = showPb2 ? 'block' : 'none'; } show(true, false); &lt;/script&gt; &lt;/apex:page&gt;   Controller  public with sharing class testPage { public string Existing{get; set;} public string NEWAcc{get; set;} public Boolean radioexisting{get; set;} public Boolean radionew{get; set;} public Employee__c pmepme{get;set;} List&lt;SelectOption&gt; ownershipValues;     public Employee__c emp{get;set;}     public Employee__c pme{get;set;}     public Employee__c emplist{get;set;}     public String var {get;set;}         public boolean editSection {get;set;}          public testPage(ApexPages.StandardController controller) {         radioexisting=true;         radionew=false;             Employee__c emp=new Employee__c();             pme=(Employee__c )controller.getRecord();             editSection =true;             var= ApexPages.currentPage().getParameters().get('Id');              system.debug('erecrrrtrtrt');                  system.debug('erecrrrtrtrt'+NEWAcc);             if(var!=null){             emplist=[select Name,Address__c,Phone__c,Job_Title__c,Salary__c,type__c  From Employee__c where id=:var];             }             }          public PageReference saving(){                         system.debug('erecrrrtrtrt'+Existing);                  system.debug('erecrrrtrtrt'+NEWAcc);             upsert pme;             PageReference p=new PageReference ('/'+pme.id);             p.setRedirect(true);             return p;             }     public PageReference pbBlockRender() {     return null;     }     public PageReference EdittheSection (){ editSection = true; PageReference pf=new PageReference('https://c.ap2.visual.force.com/apex/test6');  pf.setredirect(true); return pf;           }      public String mypbBlock { get; set; } }   iam getting the following please help to fix it     System.SObjectException: SObject row was retrieved via SOQL without   querying the requested field: Employee__c.Name
38310
Given the following classes and controller action method:  public School {   public Int32 ID { get; set; }   publig String Name { get; set; }   public Address Address { get; set; } }  public class Address {   public string Street1 { get; set; }   public string City { get; set; }   public String ZipCode { get; set; }   public String State { get; set; }   public String Country { get; set; } }  [Authorize(Roles = "SchoolEditor")] [AcceptVerbs(HttpVerbs.Post)] public SchoolResponse Edit(Int32 id, FormCollection form) {   School school = GetSchoolFromRepository(id);    UpdateModel(school, form);    return new SchoolResponse() { School = school }; }   And the following form:  &lt;form method="post"&gt;   School: &lt;%= Html.TextBox("Name") %&gt;&lt;br /&gt;   Street: &lt;%= Html.TextBox("Address.Street") %&gt;&lt;br /&gt;   City:  &lt;%= Html.TextBox("Address.City") %&gt;&lt;br /&gt;   Zip Code: &lt;%= Html.TextBox("Address.ZipCode") %&gt;&lt;br /&gt;   Sate: &lt;select id="Address.State"&gt;&lt;/select&gt;&lt;br /&gt;   Country: &lt;select id="Address.Country"&gt;&lt;/select&gt;&lt;br /&gt; &lt;/form&gt;   I am able to update both the School instance and the Address member of the school.  This is quite nice!  Thank you ASP.NET MVC team!  However, how do I use jQuery to select the drop down list so that I can pre-fill it?  I realize that I could do this server side but there will be other dynamic elements on the page that affect the list.  The following is what I have so far, and it does not work as the selectors don't seem to match the IDs:  $(function() {   $.getJSON("/Location/GetCountryList", null, function(data) {     $("#Address.Country").fillSelect(data);   });   $("#Address.Country").change(function() {     $.getJSON("/Location/GetRegionsForCountry", { country: $(this).val() }, function(data) {       $("#Address.State").fillSelect(data);     });   }); });
105378
Use Case:  What i want is a list of records, and allow this user to choose 2 of those records, then click a button to go to a new VF page, if the user selects more than 2, i want him to get a notification of some kind saying you need to select 2 records, I do not want the page refeshed though.  Strategy:  I'm creating a wrapper class for the records like this:  and i have that part going by creating a custonm controller... I need the notification part working.   Problem:  I don't know how to call methods from the customController in javascript Also, i do not want to refresh the entire page. I just want them to go back to where they were. I was thinking a pop-up notification but I'm flexible..
83258
Does anybody know of a method to trigger an event in Prototype, as you can with jQuery's trigger function?  I have bound an event listener using the observe method, but I would also like to be able to fire the event programatically.  Thanks in advance
109837
I am having trouble using apex:selectradio because of 508 compliance issues. The selectradio is creating html table tags with role="presentation" and the tool my client is using treats it as a layout table and not data table and fails to read the labels for the radio button.   The solution I have come up with is to use input type radio and pass the values to to controller, but I cannot fire submitSatisfactionComment method.  Here is my code.  VisualForce Page:  &lt;input type="radio" onclick="satisfactionComment"  name="satisfaction" value="1"&gt; {!$Label.One}         &lt;apex:actionFunction name="satisfactionComment" action="{!ctrl.submitSatisfactionComment}" rerender="myPanel"/&gt;     &lt;/input&gt; &lt;input type="radio" onclick="satisfactionComment"  name="satisfaction" value="2"&gt; {!$Label.Two}         &lt;apex:actionFunction name="satisfactionComment" action="{!ctrl.submitSatisfactionComment}" rerender="myPanel"/&gt;     &lt;/input&gt;   Apex Code:  public PageReference submitSatisfactionComment() {     //do something here with the selected value of the radio button     return null; }
92503
I have a lightning component that is using ui:inputSelect.   The component code:              &lt;div class="slds-form-element__control"&gt;                 &lt;ui:inputSelect class="slds-select" aura:id="quals" change="{!c.getPreCodes}"&gt;                     &lt;aura:iteration items="{!v.questions}" var="q"&gt;                          &lt;ui:inputSelectOption aura:id="question" text="{!q.Id}" label="{!q.Question_Text__c}"/&gt;                     &lt;/aura:iteration&gt;                 &lt;/ui:inputSelect&gt;             &lt;/div&gt;   The controller:      getPreCodes : function(cmp, event, helper){         var selected = cmp.find("quals").get("v.value");          var action = cmp.get("c.getPreCodes");         action.setParams({             "qualID" : selected         });         action.setCallback(this, function(response){             var state = response.getState();             if (state === "SUCCESS") {                  console.log('precodes: ', response.getReturnValue());              }         });          $A.enqueueAction(action);     }   The basic logic is that the uiSelect is dynamically populated on init (this works fine). When a user makes a selection the "change" parameter function is fired to retrieve a list from the database and pass it to another component.   However, the change function {!c.getPreCodes} seems to be called recursively causing a      "Something has gone wrong. AuraClientService.postProcess: error in   processing [RangeError: Maximum call stack size exceeded] . Please try   again."   error. If I comment out the enqueueAction the function only runs once (nothing is called recursively) so I suspect it has something to do with the controller call.
92658
I'm using Jquery's toggle event to do some stuff when a user clicks a checkbox, like this:  $('input#myId').toggle( function(){ //do stuff   }, function(){ //do other stuff     } );   The problem is that the checkbox isn't being ticked when I click on the checkbox. (All the stuff I've put into the toggle event is working properly.)  I've tried the following:  $('input#myId').attr('checked', 'checked');   and  $(this).attr('checked', 'checked');   and even simply  return true;   But nothing is working. Can anyone tell me where I'm going wrong?  Edit - thanks to all who replied. Dreas' answer very nearly worked for me, except for the part that checked the attribute. This works perfectly (although it's a bit hacky)  $('input#myInput').change(function () {     if(!$(this).hasClass("checked"))     {         //do stuff if the checkbox isn't checked         $(this).addClass("checked");         return;     }      //do stuff if the checkbox isn't checked     $(this).removeClass('checked'); });   Thanks again to all who replied.
92799
Several of my pages use both JQuery and Protoype. Since I upgraded to version 1.3 of JQuery this appears to be causing problems, because both libraries define a function named '$'.  JQuery provides a function noConflict() which relinquishes control of $ to other libraries that may be using it. So it seems like I need to go through all my pages that look like this:  &lt;head&gt;           &lt;script type="text/javascript" src="/obp/js/prototype.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript" src="/obp/js/jquery.js"&gt;&lt;/script&gt; &lt;/head&gt;   and change them to look like this:  &lt;head&gt;           &lt;script type="text/javascript" src="/obp/js/prototype.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript" src="/obp/js/jquery.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript"&gt;         jQuery.noConflict();         var $j = jQuery;     &lt;/script&gt; &lt;/head&gt;   I should then be able to use '$' for Prototype and '$j' (or 'jQuery') for JQuery. I'm not entirely happy about duplicating these 2 lines of code in every relevant page, and expect that at some point somebody is likely to forget to add them to a new page. I'd prefer to be able to do the following    Create a file jquery-noconflict.js which "includes" jquery.js and the 2 lines of code shown above Import jquery-noconflict.js (instead of jquery.js) in all my JSP/HTML pages   However, I'm not sure if it's possible to include one JS file in another, in the manner I've described? Of course an alternate solution is simply to add the 2 lines of code above to jquery.js directly, but if I do that I'll need to remember to do it every time I upgrade JQuery.
13185
I have created lightning quick action to add my component for some functionality.   so from my quick action. When I do some validation like       var opp = component.get("v.objOpportunity");     if(!opp.Name.length || !opp.CloseDate.length )     {         var toastEvent = $A.get("e.force:showToast");         toastEvent.setParams({             "message": 'Opportunity name and close date can not be empty.',             "type": "Error"         });         toastEvent.fire();         return;     }   So the toast message display behind the modal. Please check below screenshot.   Any solution for this issue? I don't want to write custom error message functionality to display to user.
8344
I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:  var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) {     var td = document.createElement('td');     var select = document.createElement('select');     select.setAttribute("...", "...");     select.onchange = function() {         onStatusChanged(select, callid, anotherid);     };     td.appendChild(select); }   When the onchange event is fired for a &lt;select&gt; element however, it seems like the same values are being passed to the onStatusChanged() method for every &lt;select&gt; in the table (I've verified that in each iteration of the loop, callid and anotherid are being given new, distinct values).   I suspect this is occuring because of the nature of how I am setting the event handler, with the select.onchange = function() syntax. If I understand how this is working correctly, this syntax sets a closure for the onchange event to be a function which refers to these two references, which end up having a final value of whatever they are set to on the last iteration of the loop. When the event fires, the value referenced by callid and anotherid is the value set in the last iteration, not the value set at the individual iteration.  Is there a way that I can copy the value of the parameters I am passing to onStatusChanged()?  I've changed the title to better reflect the question and the accepted answer.
92519
I have HTML like the following on my website:  &lt;div class="groups"&gt;   &lt;div class="group"&gt;     Group 1 priority:     &lt;select&gt;       &lt;option value="1.0"&gt;1&lt;/option&gt;       &lt;option value="2.0" selected="selected"&gt;2&lt;/option&gt;       &lt;option value="3.0"&gt;3&lt;/option&gt;     &lt;/select&gt;   &lt;/div&gt;   &lt;div class="group"&gt;     Group 2 priority:     &lt;select&gt;       &lt;option value="1.0"&gt;1&lt;/option&gt;       &lt;option value="2.0"&gt;2&lt;/option&gt;       &lt;option value="3.0" selected="selected"&gt;3&lt;/option&gt;     &lt;/select&gt;   &lt;/div&gt;   &lt;div class="group"&gt;     Group 3 priority:     &lt;select&gt;       &lt;option value="1.0" selected="selected"&gt;1&lt;/option&gt;       &lt;option value="2.0"&gt;2&lt;/option&gt;       &lt;option value="3.0"&gt;3&lt;/option&gt;     &lt;/select&gt;   &lt;/div&gt; &lt;/div&gt;   I am looking for a way to sort the order these groups appear in the browser using jQuery, based on the what is selected in the dropdown. It should resort when the user selects a new value in any of the dropdowns, or on page load.  What would be the easiest approach to this problem?  I have jQuery UI available, if the sortable thing can be used in any way. I couldn't not find a way to use that.  Update: There is other data in the &lt;div class="group"&gt; that should follow the dropdowns wherever they are moved. The number of groups varies from 0 to 20.
122548
I have a submit button in my form and I want to implement it using ajax:  function myid_user_page_form(){      drupal_add_library('system', 'drupal.ajax');     $form = array();     $form['id'] = array(        '#type' =&gt; 'fieldset',        '#title' =&gt; t('ID Information'),        '#prefix' =&gt; '&lt;div id="myid_search_id_number_wrapper"&gt;',        '#suffix' =&gt; '&lt;/div&gt;'    );       $form['submit'] = array(       '#type' =&gt; 'button',       '#value' =&gt; 'Save',          '#ajax' =&gt; array(          'event' =&gt; 'click',          'callback' =&gt; 'myid_user_page_form_ajax_submit',          'wrapper' =&gt; 'myid_search_id_number_wrapper'       ),        '#attributes' =&gt; array(         'id' =&gt; 'myid_save',                    ), );  function myid_user_page_form_ajax_submit($form, &amp;$form_state) {      watchdog('Wow','Wow'); }   After executing the code above, the page still has it's refresh after it's clickfunctionality. The ajax doesnt work and no Wow message log in my watchdog table from my database, which means the ajax callback function isn't called. Where am I missing?
63292
I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded.  Most of the time this is done using the window.onload function.  My question is:    Is this the best way to trigger JavaScript events on the page loading or is there a better/newer way? If this is the only way to trigger an event on the page loading, what is the best way to make sure that multiple events can be run by different scripts?
25094
I have HTML code like this :  &lt;div&gt;        &lt;a&gt;Link A1&lt;/a&gt;        &lt;a&gt;Link A2&lt;/a&gt;        &lt;a&gt;Link A3&lt;/a&gt; &lt;/div&gt;  &lt;div&gt;        &lt;a&gt;Link B1&lt;/a&gt;        &lt;a&gt;Link B2&lt;/a&gt;        &lt;a&gt;Link B3&lt;/a&gt; &lt;/div&gt;   When user clicks a link from above HTML, I want to get the jQuery object of the corresponding &lt;a&gt; element, and then manipulate its sibling. I can't think of any way other than creating an ID for each &lt;a&gt; element, and passing that ID to an onclick event handler. I really don't want to use IDs.   Any suggestions?
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