The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Javascript Inject Images in Post

View previous topic View next topic Go down

Solved Javascript Inject Images in Post

Post by Dr.Intern on February 3rd 2016, 5:56 am

Technical Details


Forum version : #Invision
Position : Founder
Concerned browser(s) : Mozilla Firefox, Google Chrome
Who the problem concerns : All members
Forum link : chaoticbackup.forumotion.com

Description of problem

I wrote a script that would replace
Code:
<div class='card'>card name<div>
with an image of the corresponding card. Got it to work in jsfiddle.
https://jsfiddle.net/epksyL69/5/

But when I tried in on the forum, nothing happened. I ticked the enable on all pages under javascript management. I don't get any errors in the console related to this script. It just isn't doing anything.

Details on this post


Last edited by Dr.Intern on February 3rd 2016, 11:49 pm; edited 1 time in total

Dr.Intern
Forumember

Posts : 77
Reputation : 3
Language : English

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by Ange Tuteur on February 3rd 2016, 4:56 pm

Hi @Dr.Intern,

The problem with your script is that it's firing BEFORE the document is ready, so when
Code:
x
gets the specified elements by classname it'll return null, because the document has not yet finished loading ; the elements don't yet exist. Note that all scripts in the AP execute in the HEAD section so you should wrap your code with the following :
Code:
$(function() {

});

The above is shorthand for :
Code:
jQuery(document).ready(function() {

});
This should give a brief explanation : http://www.w3schools.com/jquery/jquery_syntax.asp

You can also use this if you want to stick with native.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by APE on February 11th 2016, 5:39 pm

Hello @Dr.Intern Is this now Solved ?




APE
Manager
Manager

Male Posts : 8618
Reputation : 751
Language : fluent in dork / mumbojumbo & English haha
Location : STUCK IN FORUMOTIONS SERVERS HELP ME !!!!!!

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by Dr.Intern on February 11th 2016, 6:00 pm

Yes it is. I had marked solved. Thought that would be enough.

For future reference, should I also respond solved? Thanks.

Dr.Intern
Forumember

Posts : 77
Reputation : 3
Language : English

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by APE on February 11th 2016, 6:06 pm

we just like to make sure as there was no reply after the thank post

it would be really nice if you could reply to the Solved post then we would not see it fit to ask LOL

You would not believe it when i say we lock solved icons and some one comes running to us in PM saying Oi you closed my post and it was not solved.

We say why mark it as solved and the reply to that is i must have hit it and not see i have done it

Anyway Thank you .......

Topic solved and archived




APE
Manager
Manager

Male Posts : 8618
Reputation : 751
Language : fluent in dork / mumbojumbo & English haha
Location : STUCK IN FORUMOTIONS SERVERS HELP ME !!!!!!

http://chatworld.forumotion.co.uk/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum