简体   繁体   中英

How can I use jquery and webresource in Microsoft Dynamics CRM 2011?

I have downloaded latest version of jquery and added file to web resources. I have added this resource to the library of the form where I intended to use jquery, but when I tried to use simple function it didn't work. JQuery is on top of the library list.

I tried different approach with customizing quote form by adding web resource to a form with the following code:

<html>
<head><meta charset="utf-8"></head>
<body>

    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>    

<form>
    <input type="file">
</form>

<script> 
    $(":file").change(function()
    {
        alert($(":file").val());
    }); 
</script>
</body>
</html>

When I try to run this code in CRM I get this message "Error: '$' is undefined". If I save this code to ie index.html it works. I was following instructions from the links bellow but without success.

http://crmconsultancy.wordpress.com/2011/06/13/using-jquery-in-crm-2011/ http://thecrmworld.wordpress.com/2011/05/15/how-to-add-jquery-support-to-crm-2011/

Don't use external links as they are not reliable. This post explains exactly how to bind jquery into your web resource. how do you add jquery in a html page as a web resource in dynamics crm 2011

If you want to use jQuery you don't have to import the library. If you use parent.$ you are going to use the jQuery library of Dynamics CRM.

If you want to try the Javascript before uploading to a web resource follow this link https://dynamicscrm365helper.blogspot.com/2018/07/how-to-try-crm-javascript-before.html You only have to change the Xrm.Page.getAttribute()...with

parent.$('input#file').on('change',function() {
parent.$('input#file').val()
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM