3

I have a Lightning app which was working fine, before Summer'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 Summer'16 release.

Update:

Locker Service is Deactivated

It is the same even when it is Activated

  • For any javascript questions this release, please specify whether or not you have Locker Service enabled. In this case, if it is enabled, try disabling it to at least see if that is the root cause. Also I think you mean Summer '16? – Adrian Larson Jun 21 '16 at 18:38
  • Updated my question, Locker Service was disabled, it was giving the same error when even it is enabled. – BigHairDev Jun 21 '16 at 18:54
  • Usually it being enabled breaks stuff. hence the recommendation to try disabling it. I guess it already was so the culprit must lie elsewhere. – Adrian Larson Jun 21 '16 at 18:54
  • Yes! it seems like that, as I told it was working very well before Summer'16 thus, there's nothing with code hopefully. – BigHairDev Jun 21 '16 at 19:07
  • I spoke with SF, this gives the answer, Reference Link : developer.salesforce.com/blogs/developer-relations/2016/04/… – BigHairDev Jun 22 '16 at 5:47
0

After speaking with SF executive,

Every new Org which is created after Spring 2016 release will have Locker Services enabled for communities (at ORG Level) and for whole ORG (at SF level)

To disable Locker Services for whole Org, you need to speak with SF Customer Service, then you'll see an option in Critical Updates for disabling Locker Service for whole ORG.

For old orgs which were created before Spring'16 release will already have an option for disabling Locker Service for whole Org in Critical Updates.

All components installed from Managed Packages will NOT have any Locker Service enabled.

All the above are confined just for Spring'16 Release, everything will have Locker Service enabled from Winter'17 release.

What is with this Locker Service:

SF is increasing security by not allowing access of DOM element functionality like, .parent/innerHTML etc. (there are many) and all these features are enabled/disabled with Locker Service either at ORG level or SF level (dependent on org creation date)

There's NO best way around as SF will be removing the option of disabling Locker Service from Winter'17 release (Even at ORG level or SF level) from everything <> and makes sure everyone use functionality provided by SF.

How can we access DOM in future?

SF is providing certain level of functionality by having its wrappers around it, they are adding/removing functionalities on daily basis, thus, there is no count of functionality yet. (Someone please add if you can find it)

All of the above is for Lightning Components ONLY

Food for your brain:

link 1

Lightning CLI:

link 2

Guide:

link 3

Rules:

link 4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.