Skip Navigation

[Resolved] How to add JS to Toolset

This thread is resolved. Here is a description of the problem and solution.

Problem

How can we use JS in a Toolset View or Content Template?

Solution

JS is added to the JS Editors under each of the relevant HTML editors.
This can be found in the Loop and Filter section, but as well under Content Template HTML editors.

There are also several hooks you can use when you press the button "Front-End Events" in the JS Editor for a Views Filter.
These are so to add your code after special Toolset related events using AJAX for example.

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by Charles 6 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#621597
Screen Shot 2018-03-03 at 12.10.52 PM.png

Hi,

I'm trying to invoke a JS function commaFormat() that adds thousands separator to large numbers. I tested the function working using alert(commaFormat(1000000)); to print on screen in the JS editor section (see attached screenshot) and it works.

However when I tried to call it in View editor it doesn't work:

<script>alert(commaFormat(1000000));</script>

What's the right way?

#621689

JS is added to the JS Editors under each of the relevant HTML editors.
This can be found in the Loop and Filter section, usually.

There are also several hooks you can use when you press the button "Front-End Events" in the JS Editor.
These are so to add your code after special Toolset related events using AJAX for example.

I am not sure you will be able to change the format of the numeric field like that, thou.

I have a request in place so to allow nicer number formats in numeric fields - but this is not yet in the development plans, but it is accepted as a request.

#623530

Thanks Beda.

I hope this number format feature can be made a priority because it looks very unprofessional on commercial and real estate sites dealing with large numbers especially.