function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robert_S_HarperRobert_S_Harper 

Advanced samples fo Custom Components and apps

I want to work on creating an application that contains components in such a way that the controller can modify some of the page's, element's event handlers and be able to provide custom actions automatically without the person writing the page to having to replicate all of the JavaScript and other code to provide the functionality.

 

OK a lot like the autocomplete controller from S Labs.

 

You may be asking me why? Well the main reason is I want to learn how to do this and second, I want to change the way it works and see if I can make it more generic and be able to search more than just the name field for an object.

 

All of the samples I've found so far are far too simple to show how to hook into the event handlers and inject my script into the page's elements.

Best Answer chosen by Admin (Salesforce Developers) 
Robert_S_HarperRobert_S_Harper

Thanks for all the help. As it turned out, there were some errors in the script that were causing the script to fail but no notification of what it was. Make very sure your script is 100% error free.

All Answers

Robert_S_HarperRobert_S_Harper

It looks l'm having an issue with the JavaScript my script is not setting the element's event handlers. For example I have in my custom controller

 

document.getElementById( "{!targetElement}" ).onkeyup = function handleKey(){ alert(  "handleKey()" ); }

 

When I do something like this in a static HTML page it works. The Id of the element is being correctly resolved to the same Id as the mangled name that SalesForce creates for the object. I added onmouseover="alert( this.id + ' ' + this.onkeyup ) to the targetElement's attributes and I get the Id of the element as expected but null for the this.onkeyup. When I do exactly the same thing in a static HTML page, I have the definition of the handleKey() function as well as the Id of the element.

 

What could be going on?

Robert_S_HarperRobert_S_Harper

It is starting to look like most of my problem is that the component's script is not being executed.

 

Any ideas as to why?

Robert_S_HarperRobert_S_Harper

Thanks for all the help. As it turned out, there were some errors in the script that were causing the script to fail but no notification of what it was. Make very sure your script is 100% error free.

This was selected as the best answer