[Resolved] Run javascript code on load detail view

Hello experts
I want to run some JavaScript code when page (Detail view of Task Module load). Where should i write this code so that it run on load of detail view . Please help

#sings Goooooogle (or DuckDuckGo) is your frieeeeeend :slight_smile:

There are lots of tutorials on how to do this! Some are about the EditView and some are for DetailView.


Have fun!

1 Like

Thank you so much sir it work one more question please when i do any change in JS code then every time i have to do rebuild and repair ? like repair js files and repair minified js files etc please clear this

I’m a woman.

If you go to Admin Panel > System Settings and enable Developer Mode
This will stop the application from caching the view defs, so if you change your JS it should be applied after a quick refresh (or hard refresh) of the browser window without needing to do RepairJS.

I recommend after you have completed your development/changes then you untick it as the caching does improve performance speeds.

Hope that helps.

Ok sorry ma’am .But developer mode is on even my changes are not reflecting .
I am just changing the message “Hello world” to “Hello” It shows “Hello world”.

See this please: https://www.loom.com/share/e5f6a2633b9a4af59af147c957c64b9a

I think, that you should clean cache (delete local js files) of your browser.

Hmm, that doesn’t sound normal. Can you send a screenshot that the development mode is enabled.

What solution did you go with to implement the javascript/alert?

Can you provide us the DetailView defs, the javascript file.

Usually I just need to do the hard refresh (Shift + F5) when developer mode is on/off

No Problem now its working fine. Thank you ma’am

1 Like

I want to run a javascript in detail view. I have succeeded in that too. But the javascript code I added, runs 2 times each time.

For example, I’ve included a javascript file that just throws a warning. The code is below.
Every time I refresh the page, this warning message comes up 2 times in a row.
why could it be?

I edited detailviewdefs.php file as follows.

      'includes' => 
      array (
        0 => 
        array (
          'file' => 'modules/Contacts/Contact.js',
          'file' => 'custom/modules/Contacts/js/mytest.js',

Contents of my mytest.js file;


        window.alert("this is test");

chequea la función unbind()