How to make it so pressing enter doesn't cause the comment to post?

Allon Prooit Posted in Beginning Developers 4 years ago

Wanting to make it so that you can have multiple lines in the comments field. I have upgraded OssnComments to include a button for submitting the comments. Would like to make it so that when you press enter you get a break and can enter comments on successive lines. How do you do this? Any thoughts?

Replies
us Allon Prooit Replied 4 years ago

I actually had to change it in 4 places... In entity/comment_add.php too. What version of php are you using? I'm using php 7.2 now. It works on your site, should work on mine too.

us Roman Lohov Replied 4 years ago

Here is how it sopose to look:

$text = $('#comment-box-<?php echo $object; ?>').html();
                $text = $replace_tags($text, '<div>').replace(/\<div\\?>/g, "<br>");
                $text = $replace_tags($text, '<br>').replace(/\<\/div\\?>/g, "<br>");
                $text = $replace_tags($text, '<br>').replace(/\<br\\?>/g, "\n");

YOU and only you, have to edit it 3 times, and set to "True" in JS 2 times.

us Roman Lohov Replied 4 years ago

I honestly don't know how to help you at this point. Everything had been chewed up. I can only guess you didn't edit something right.

us Allon Prooit Replied 4 years ago

Ok, how on earth did you get all that? Anywho, glad you could get it to work. Why is it not working on my site?

us Roman Lohov Replied 4 years ago

Just because i'm bored and wanted to see what is up. I grabbed your submit button with a extra JS you had in comments_add. Everything works.enter image description here

us Allon Prooit Replied 4 years ago

I did! In order to keep from causing a submit on enter I had to change the 2 false statements to true. In order to get the non-breaking page space between the lines I had to use ~Z~ Man's addition. Now, what do I need to get a breaking space or a div between the two lines?

us Roman Lohov Replied 4 years ago

Now we probably just confusing other people.

change the 2 false statements

Did you add 2 extra lines Z-man provided to those 2 statements as well?

us Allon Prooit Replied 4 years ago

Pardon... it now gives one non-breaking page space on submit.

us Allon Prooit Replied 4 years ago

Ok, so I checked that file and sure enough, there was a secondary JavaScript I had to edit. Now it gives one breaking space but no <br> or \n after the enter. Secondly, you still have to change the 2 false statements to true to keep it from posting when you hit enter.

us Roman Lohov Replied 4 years ago

Allon Prooit
As Z-man said:

I have no idea about your 'upgraded' OssnComments component...

As I looked at your code, you have implimented submit button, so the code you have to edit is not in JS folder, it is in:
OssnComments/plugins/default/forms/OssnComments/post/comment_add.php

When paying someone for addons, check what they add.

Premium Version

Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.

$199 (Life Time)
Learn More

Other Questions