You need to sign in to do that
Don't have an account?
TheCustomCloud
jQuery on a standard layout button
Has anyone been able to get jQuery to work in a custom button for a standard page layout? All the examples I can find are on custom VF pages :(
Example code or a link to example code would be very much appreciated.
Thank you.
You have to use the REQUIRESCRIPT function and link to an external resource (there's no URLFOR function available in javascript buttons sadly). There are some mirrors of jquery on google's CDN, which I'd reccomend looking up and using.
Like this:
{!REQUIRESCRIPT("http://example.org/jquery.js")}
$().stuff();
All Answers
You have to use the REQUIRESCRIPT function and link to an external resource (there's no URLFOR function available in javascript buttons sadly). There are some mirrors of jquery on google's CDN, which I'd reccomend looking up and using.
Like this:
{!REQUIRESCRIPT("http://example.org/jquery.js")}
$().stuff();
Thanks Ca_Peterson. I am wary of using a library that is controlled by an outside source but I believe you are right that this is the only way currently. Or I could host it external to SFDC on one of the client's hosts but that is messy too.
You can crate a Static Resource in SFDC named jquery_1 or something like that. And instead of using the external link, you can use this:
{!REQUIRESCRIPT('/resource/jquery_1)}
That's awesome, I had no idea they provided URLs without the version string in them. Obviously cache could be an issue here, but as long as your static resource updates aren't time senstivie (they're static after all...) that path should work.
You rock!