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.

Text Edit Buttons Not Work Anymore? After a simple HTML

View previous topic View next topic Go down

Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 24th 2012, 2:26 am

Recently I just went to click one of the text_edit controls (bold,underline, img, and so forth) now none of them work. Checked my console error and this is what is showing


Uncaught TypeError: Cannot read property 'selectionEnd' of undefined en.js:1
bbstyle en.js:1
onclick

Checked that code and well it is not closed or nothing. it ends just like so

Code:
bbtags[49]='[/sub]';bbtags[50]

Only codes I added recently added was some html, which I now know is causing the issue...but why!

Code:
 <!-- BEGIN switch_user_logged_in -->
 <span class="createMessage"><span>Create Message</span> </span>
<div id="messagePop" class="messagePopper">
                                    <div id="light" class="white_content">
                                      <div class="topborder"><span>NewMessage</span></div>
                                      <div class="formbody">
                                        <form id="privatemessage" action="/privmsg" method="post" name="post" class="newmessage">
                                        <input placeholder="Message To:" name="username[]" type="text" class="usernameinput"/>
                                        <input placeholder="Subject:" onkeypress="if (event.keyCode==13){return false}" maxlength="64" name="subject" type="text" class="usernameinput"/>
<textarea class="noThis" placeholder="Type Your Message Here..." name="message"></textarea>
</form>
                                        </div>
    <div id="bottombuttons">
<span class="button"><button onclick="document.getElementById('privatemessage').submit();" class="submitbutton uiButton uiButtonConfirm uiButtonLarge">Submit</button>
       
    <button class="submitbutton cancelButton uiButton uiButtonConfirm uiButtonLarge">Cancel</button></span>
</div>
                                          </div>         
  <div id="fade" class="black_overlay"></div>
                                          </div>
<!-- END switch_user_logged_in --> 



One thing I did see is that the Form Validation code from Rideem3 throws 10-80 console errors stating its an unverified request, in show ads or something like that. I deleted that right away rambo
Please help me get this fixed. Thank you.

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 24th 2012, 8:32 pm

Ok thanks Rideem. Didn't mean to make you sound bad, I was just frustrated because I had like 78 console errors, 40 were from the text edit buttons, and 38 from fmquery and never happened before. When I delete the html, it works, but how is basic html messing with the text edit buttons??? Its crazy. The only thing I may think of is to much characters in the template? But I deleted the CSS style I added to the head and same thing so it can't be that. Any suggestions, do you think maybe I should use js to append it to the location?

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 24th 2012, 8:49 pm

No I have yet to insert the new Validation code. I am focusing on why in the world an html code is giving issues to the text edit buttons. I just tried this code;

Code:
(function($){
$(document).ready(function(){
$('#searchingbox').append('<span class="createMessage"><span>Create Message</span></span><div id="messagePop" class="messagePopper"><div id="light" class="white_content"><div class="topborder"><span>NewMessage</span></div><div class="formbody"><form id="privatemessage" action="/privmsg" method="post" name="post" class="newmessage"><input placeholder="Message To:" name="username[]" type="text" class="usernameinput"/><input placeholder="Subject:" onkeypress="if (event.keyCode==13){return false}" maxlength="64" name="subject" type="text" class="usernameinput"/><textarea class="noThis" placeholder="Type Your Message Here..." name="message"></textarea></form></div><div id="bottombuttons"><span class="button"><button class="submitbutton uiButton uiButtonConfirm uiButtonLarge" onclick="document.getElementById(\'privatemessage\').submit();">Submit</button><button class="submitbutton cancelButton uiButton uiButtonConfirm uiButtonLarge">Cancel</button></span></div></div><div id="fade" class="black_overlay"></div></div>');​​​​
});
})(jQuery);

yet that is throwing an Unexpected Token: Illegal console error.... The code works in jsfiddle.

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on November 24th 2012, 10:11 pm

en.js is the Javascript file of Forumotions loaded into english boards. The error indicates trying to read the selectionEnd property on undefined as it says... since selectionEnd is supposed to be used on textareas... (and only in firefox) then it is clear that it is not in this case, causing your error.

Your actual problem is down to the fact that your textarea is named 'message', where names should be unique, and there is already one called 'message', from the main post form. So when the function bbstyle (which the error is coming from) looks for document.post.message (in order to insert the tags) it is not giving the textarea but instead a NodeList object (containing both the original textarea named message and your own) so the "selectionEnd" property does not exist. Wink

So HTML can cause issues, if you don't conform to the correct rules. ID's should be unique, and generally names should be (with the exception of a few form elements).

Your problem should (hopefully) resolve if you rename your added textarea.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 24th 2012, 10:45 pm

ok Thanks LG I'll give er a whirl

By changing the name="message" , the feature no longer works correctly. :X

Also still does not work text edit buttons..

I still get the same console error.

ANOTHER EDIT:

CONSOLE ERRORS:

3Uncaught TypeError: Cannot read property 'selectionEnd' of undefined

Uncaught TypeError: Object function (a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e} has no method 'contents' 99980.js

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 25th 2012, 11:23 pm

No I know Rideem, I renamed it. I gave it a unique name. Which then in turns defeats the purpose of the function.


nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 26th 2012, 1:42 am

Error Console:

Uncaught TypeError: Cannot read property 'parentNode' of null

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on November 26th 2012, 8:37 pm

Where are you using the code? The previous script will only work in pages where the editor exists.

We're gonna need more details, where are you using your form? And what has been done with the default editor? What is your HTML now?

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 27th 2012, 8:48 pm

This html code is used for all pages. Its an easy pm feature thats all

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 28th 2012, 4:11 am

Even if I make the code work from Ajax?

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on November 29th 2012, 6:42 pm

You can send a PM with AJAX like so:
Code:
$.post('/privmsg', {
    'username%5B%5D' : 'Admin',
    subject : 'AJAX PM',
    message : 'Hello there!',
    folder : 'inbox',
    mode : 'post',
    post : 1
}, function(r) {
  alert('PM is sent!');
});
Or at least I'm pretty positive that is all the data that is needed.

Of course you'll have authorize unofficial forms so the authorization codes aren't needed.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 29th 2012, 10:56 pm

hey LG, I have a simple plugin by malsup seems to work though do you think itll work for this?


I see your code LG. But you have preset data, this function is used for all users to pass PM to any user they choose.

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on November 30th 2012, 9:37 pm

Well it doesn't have to be preset data...

Code:
function send_quick_pm() {
    $.post('/privmsg', {
        'username%5B%5D' : document.getElementById('quick_pm_username').value,
        subject : document.getElementById('quick_pm_subject').value,
        message : document.getElementById('quick_pm_message').value,
        folder : 'inbox',
        mode : 'post',
        post : 1
    }, function(r) {
      alert('PM is sent!');
    });
}

Just get creative with it.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on November 30th 2012, 9:46 pm

Ok I gotcha now. will the name="message" still effect the text edit buttons? or would i not need name anymore with the ajax code

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on December 2nd 2012, 1:38 pm

A name wouldn't be needed really. In the script you can see I hypothetically gave the textareas an ID of 'quick_pm_message', you could roll with that or one of your own.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on December 2nd 2012, 8:55 pm

Yeah I tried the code above, for some reason it did not work,

do i have to type in the onClick function? onClick="send_quick_pm();"

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on December 2nd 2012, 9:18 pm

I thought so HAHAAHA sorry I've been working on this one code for last 73 hours and finally everything is working haha. Ok I'll try the onClick event

ok another question, do I have to change any of the form tag data? I deleted the action=? this is the new form I have

Code:
<form id="privatemessage" method="post" name="post" class="newmessage">
<input id="quick_pm_username" placeholder="Message To:" type="text" class="usernameinput"/>
<input id="quick_pm_subject" placeholder="Subject:" onkeypress="if (event.keyCode==13){return false}" maxlength="64" type="text" class="usernameinput"/>
<textarea id="quick_pm_message" class="noThis" placeholder="Type your message here..." ></textarea>
  </div>
<div id="bottombuttons">
  <span class="button"><button onClick="send_quick_pm();" class="submitbutton uiButton uiButtonConfirm uiButtonLarge">Submit</button>
  </form> <button class="submitbutton cancelButton uiButton uiButtonConfirm uiButtonLarge">Cancel</button>
  </span>
</div>

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on December 3rd 2012, 12:13 am

It would be wise to remove both form tags to prevent it submitting when enter is pressed. Also the fact that the name conflicts with the current editor, and also your closing form tag is in an invalid place and not conforming to correct nesting. (the closing tag is inside a DIV when the opening tag is well outside that DIV. Invalid HTML takes longer and more resources to load, parse and render Wink )

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on December 3rd 2012, 4:40 am

Yeah I set it like that to form the area correctly. I'll change it up and fix all the things wrong with it. So no form tags? Just regular inputs and submits

Also it did not work at all, it would submit but do nothing in the message area. I'll fix the coding, and take form tags out adn see what happens


Ok, so I left the <form> tags in, fixed the markup though. and its succeeding the function, just not passing the to the inbox

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on December 3rd 2012, 10:30 am

Well no, you need to do that in the callback function. It's sending the data, you now need to decide what the page does. Whether you want to redirect to the inbox or just let the user know its sent. These things don't happen on their own.

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on December 3rd 2012, 10:34 am

No you misunderstood me. I get the alert, but there are no new messages.

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by LGforum on December 3rd 2012, 10:38 am

So it has or hasn't sent? Is it in the outbox/sentbox?

LGforum
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Text Edit Buttons Not Work Anymore? After a simple HTML

Post by nextlevelgaming on December 3rd 2012, 3:32 pm

No not in either. So hasn't sent.

nextlevelgaming
Forumember

Male Posts : 989
Reputation : 38
Language : English|CSS|HTML5|javascript|
Location : New York

http://www.easybbtutorials.forumotion.com

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