You need to sign in to do that
Don't have an account?
DNLZ
Including Javascript in New/Edit pages with a Visualforce Page
The title says it all, i created a visualforce page with some javascript in it:
<apex:page standardController="Aangebodenobject__c"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> <script type="text/javascript"> var $_org = jQuery.noConflict(); $_org("#CF00NU0000002waYc").change(function(object){ $_org("#Name").val($_org("#CF00NU0000002waYc").val()); }) </script> </apex:page>
This bit of JS is used to populate the name field when a lookup object is selected pretty straight forward. So i added this as a Visualforce page to the edit layout but when i check the source this page isn't rendered ?! What am i doing wrong any tips?
Thanks,
Daniël
the only way in a page layout that i could think of is to add a custom button that executes a javascript. you do all the operations there... manual (i.e. one has to push the button).
if you're open to using a visualforce page instead of object layout...
create vf page with standardcontroller for your object, add your javascript then add <apex:detail /> and save it.
go to related object, then override the standard button for Add / Edit with VF page you just created.
more here about overriding standard buttons and link
All Answers
when you add a VF page to an object page layout, it is embedded as <iframe>
go search for it in the source of generated page.
I made a mistake, this is only visible when viewing an object. The visualforce page components aren't rendered when editing or creating an object. Is there any other way to include JS on an edit / new page ?
the only way in a page layout that i could think of is to add a custom button that executes a javascript. you do all the operations there... manual (i.e. one has to push the button).
if you're open to using a visualforce page instead of object layout...
create vf page with standardcontroller for your object, add your javascript then add <apex:detail /> and save it.
go to related object, then override the standard button for Add / Edit with VF page you just created.
more here about overriding standard buttons and link
Noce one, i managed to create a custom home page element and execute javascript inside it. Then check the url for the object identifier (in my case this was a06 check the url with indexOf and if it returned true include the js that needs to be executed but it felt like a hack. Changed to custom page with Js in it! Thanks for your thoughts :)
the <apex:detail /> isn't working on the new/ edit pages. Is there any other component that will render my new/ edit page? I dont want to keep editting this code if my objects gets new fields....