• Shivateja Madipalli 32
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have a Lighting app which was working fine, before Spring'16 release.

There were issues with Jquery 3.0 thus, downgraded to Jquery 2.2.4;  When I am trying to access html select element, it is giving undefined.

I am accessing html select element's selected value on 'onchange' event,
var selectedVal = $('#'+event.srcElement.id).val();

This is giving an error:

Something has gone wrong. Action failed: c$PsetComp$controller$permissionSetNamesddlChange [TypeError: undefined is not an object (evaluating 'options.length')]
Failing descriptor: {c$PsetComp$controller$permissionSetNamesddlChange}.
Please try again.


It is trying to access the length of options to find the selected value but as the element itself is undefined it is giving an error.

Same happened even when I have tried with html select element's id instead of event.srcElement.id

var selectedVal = $('#selectElementId').val(); 

The most interesting fact is, I am able to add options dynamically, i.e., there is no problem with accessing the html element but the issue is with accessing val();

      var fragment = document.createDocumentFragment();
      var opt = document.createElement('option');
      opt.innerHTML = "Chooseoption";
      opt.value = "Nothingelected";
      fragment.appendChild(opt);
      $('#permissionSetNamesddl').append(fragment);


 The above code isn't giving any error.

All of it was working fine before Spring'16 release.
I have a Lighting app which was working fine, before Spring'16 release.

There were issues with Jquery 3.0 thus, downgraded to Jquery 2.2.4;  When I am trying to access html select element, it is giving undefined.

I am accessing html select element's selected value on 'onchange' event,
var selectedVal = $('#'+event.srcElement.id).val();

This is giving an error:

Something has gone wrong. Action failed: c$PsetComp$controller$permissionSetNamesddlChange [TypeError: undefined is not an object (evaluating 'options.length')]
Failing descriptor: {c$PsetComp$controller$permissionSetNamesddlChange}.
Please try again.


It is trying to access the length of options to find the selected value but as the element itself is undefined it is giving an error.

Same happened even when I have tried with html select element's id instead of event.srcElement.id

var selectedVal = $('#selectElementId').val(); 

The most interesting fact is, I am able to add options dynamically, i.e., there is no problem with accessing the html element but the issue is with accessing val();

      var fragment = document.createDocumentFragment();
      var opt = document.createElement('option');
      opt.innerHTML = "Chooseoption";
      opt.value = "Nothingelected";
      fragment.appendChild(opt);
      $('#permissionSetNamesddl').append(fragment);


 The above code isn't giving any error.

All of it was working fine before Spring'16 release.