Quote buttons not working due to jQuery - SMF 2.1 beta 3

Started by lofac, September 30, 2018, 09:42:10 PM

Previous topic - Next topic

lofac

Hello,

I can't get the Quote and Quick Edit buttons that are under each post to work.
I run a script that uses jQuery, it is placed in main index.php
It has caused few more issues with it but I managed to fix those but can't fix this quote buttons so far.

So far, I've tried:
-Change jQuery option in forum settings from auto to local, and custom while putting a CDN link there. All of these attempts would only get the quote buttons to work if i remove the jQuery script url but then my script won't work.
-Try different jquery versions in script code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

I've tried couldflare's jquery, google, and others with different versions and the problem seems just in jquery itself being used.

on Chrome Network debug shows this after I click on quote button
<script

src
="
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
"
>
<parsererror

style
="
display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black
"
>
<h3
>
This page contains the following errors:
</h3
>
<div

style
="
font-family:monospace;font-size:12px
"
>
error on line 3 at column 1: Extra content at the end of the document
</div
>
<h3
>
Below is a rendering of the page up to the first error.
</h3
>
</parsererror>
</script>


Any idea on how to fix this?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

lofac

Quote from: Kindred on September 30, 2018, 09:47:14 PM
Don't use beta 3.
Yeah I think I made a bit of a mistake there, but only knew too late...
But does that mean my problem is being caused by this specific version of the software? No hope in a possible fix?
Any suggestions? Could i safely downgrade/upgrade?

Kindred

Well, you can not downgrade.

It's a beta... it's an old beta that has had hundreds of fixes applied to it in preparation for the next beta/RC...   

Is this a new site?

If so, just remove the installation and install 2.0.15

If not...  then restore the backup that you took before you upgraded to a beta version..
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

lofac

I might upgrade to the github version soon.
But I'd wait if anyone else could help me fix this issue.

I wonder is this issue happening due to a bug in beta 3?

Arantor

Its likely that whatever script you're trying to run is what's breaking it... but upgrading to a beta version that isn't a year old might help you...

It also might help if you explained this extra script you've tried to add and what other changes you've made to accommodate it.

lofac

I haven't removed or edited any SMF code. Just added that 3 lines script.
It's not the script that is breaking this, because if i remove the jquery line, the script doesn't work but then the quote buttons work.
but if i put back the jquery line, the script works but then the quote buttons gets broken.

You gave me an idea, where exactly should i place the script in the index.php file?

To give you an idea; I've tried placing it after and before function calls like loadDatabase(), reloadSettings(), loadBoard() etc.. but placing it in such places sometimes would work but breaks something.
So right now it seems to be best placed after loadUserSettings(); and before loadBoard();

Forgive me if I'd make you facepalm about this, but I have no knowledge about PHP and just trying to fix things but changing stuff.
But I can confirm that I've made no code changes.

Arantor

Except you HAVE made a change, to add three lines, except you won't say what the three lines actually are that you added...

And you can't just shove code in anywhere, unfortunately.

lofac

Sorry, didn't mean not to show it
echo '
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
        $(document).ready(function(){
$(\'body\').find(\'img[src$="http://www.example.com/image.png"]\').remove();
    });

</script>';

Arantor

The correct place for this script is in your theme's index.template.php file, at the bottom just before the </body> tag, after jQuery has loaded on the page, so you don't need to include it again.

Though if you're doing is removing images... I'm sure there are better ways. What image are you trying to remove exactly?

lofac

This worked just perfect!! really appreciate your help and taking the time to reply!

Advertisement: