0

I am upgrading crm 2011 to crm 2016 onpremise, due to new rendering engine of newer version so many javascript code is not working. Recently getting issue with iframe where I am unable accessing iframe contents using JQuery.

var ccControl = $("#WebResource_ccCheckList").contents().find(":checkbox"); if(ccControl) { //Business Logic }

The element I want to access is an html input with id of 'myChckboxId': Are you Agree ? getting ReferenceError: '$' is undefined Error although $ reference working fine with scripted in IFrame. tried following workaround to fix but not working for me :

1)Put following script on onload.

if (typeof($) === 'undefined'){ var script = document.createElement('script'); script.src = 'ajax.googleapis.com/.../jquery.min.js'; script.async = false; document.head.appendChild(script);}

2) $(Xrm.Page.ui.controls.get('WebResource_ccCheckList').getObject()).contents().find(':checkbox').val(); Xrm.Page.ui.controls.get('WebResource_ccCheckList').getObject() is giving me obj but not works with $.

3) Xrm.Page.ui.controls.get("WebResource_ccCheckList").getObject().contentWindow.document.getElementById('myChckboxId');

Getting Null

Please suggest any alternate approach to resolve the issue.

Thanks

user222419
  • 11
  • 5

1 Answers1

1

jQuery is still there, it's just above you:

$ = ($ || parent.$); 
// Now you have $
Alex
  • 23,004
  • 4
  • 39
  • 73
  • Mandatory warning: manipulating the DOM is never a good idea (with each update the code might need to be rewritten from scratch) – Alex Oct 21 '16 at 10:49