Preexecute JQuery

24 views
Skip to first unread message

Heather Napoleone

unread,
Feb 13, 2018, 5:02:43 PM2/13/18
to RedDot CMS Users
I was wondering if I can preexecute a jquery function before my page publishes.  I want the function to run before it gets publishes.  Putting a preexcute tage around it, does not work.

For example I want to add a class to all images that have a width of less than 200.  I don't want this function to be seen on the published page and just have the class on all the images that are less than 200 in width.  

Gavin Cope

unread,
Feb 13, 2018, 9:44:32 PM2/13/18
to reddot-c...@googlegroups.com, Heather Napoleone

Short answer is no.

If you want to run Server-side JavaScript, you could try Node.js.

Cheers,

Gavin

On 14 February 2018 08:02:47 Heather Napoleone <heathern...@gmail.com> wrote:

I was wondering if I can preexecute a jquery function before my page publishes.  I want the function to run before it gets publishes.  Putting a preexcute tage around it, does not work.

For example I want to add a class to all images that have a width of less than 200.  I don't want this function to be seen on the published page and just have the class on all the images that are less than 200 in width.  

--
You received this message because you are subscribed to the Google Groups "RedDot CMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reddot-cms-use...@googlegroups.com.
To post to this group, send email to reddot-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/reddot-cms-users.
For more options, visit https://groups.google.com/d/optout.

Mario Brandt

unread,
Feb 14, 2018, 5:39:59 AM2/14/18
to reddot-c...@googlegroups.com

You could do that with asp. (vbscript or jscript)

Or add an attribute from the image into the image tag as a class.

 

Cheers

--

Hilmar Bunjes

unread,
Feb 14, 2018, 10:59:20 AM2/14/18
to RedDot CMS Users
As Mario said you could use JScript via ASP. However, I do not recommend that.

In most cases you would use a scripting language like PHP and get the image width via attribute. Then you can write it like that:
<img class="<?= (<%att_image_width%> > 200) ? "myclass" : "" ?>" src="<%img_image%>">

In the example above you should make sure that img_image is set or that the check for width can handle an empty value if img_image is not set yet.

Best,
Hilmar
Reply all
Reply to author
Forward
0 new messages