Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8634845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:49:14+00:00 2026-06-12T09:49:14+00:00

My application includes a typeahead feature when a user is typing into a comment

  • 0

My application includes a typeahead feature when a user is typing into a comment box. In a similar fashion to Facebook’s and google+’s it will perform a lookup of users and suggest them as tags on the fly.

When a user selects one of the offered tags it gets entered into the input area as an element.

I decided to use a conenteditable div for this, but have come across a few issues.

It turns out that firefox wont delete the inserted elements when they are set to contenteditable false whereas every other major browser does.

In order to work around this I have set the inserted ‘user’ tags as contenteditble=true and wrote a quick jquery workaround to solve this issue.

It works perfectly apart from one major issue. If there are multiple tags in the area and the first of them is not proceeded by any text, then when the user deletes the final one (assuming deletion with the backspace key from right to left) the caret gets positioned incorrectly following that final deletion.

Typing again appears to then return the position to normal.

This issue only occurs in Firefox

Here is a jsFiddle showing the issue:

http://jsfiddle.net/gordyr/PESky/

Place your cursor at the end of that last tag and then hold down the backspace key until all elements are removed. You will see that the cursor/caret moves up and out of position.

It is quite possible that this is actually a bug in firefox itself, however I am looking for a workaround of some kind as without this automatic element deletion with javascript, the don’t get removed at all.

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:49:15+00:00Added an answer on June 12, 2026 at 9:49 am

    It appears that FF leaves some dirt behind, but you can clean it up by adding:

    if (!$.trim(el.text())) {
        el.empty();
    }
    

    This will check if the innerText of the contenteditable only contains spaces or newlines/breaks. If it does, just empty it. Seems to work in my test: http://jsfiddle.net/cBZ7k/

    Side note: you should probably use keydown instead of keypress for webkit support. Also, e.which is enough to get the keyCode, jQuery normalizes this event property for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've been developing an Android application which includes Google Adsense. However there seems to
My application includes a send feature which presents a list of installed programs to
I have created an Android application that includes some unit conversion tools built into
I use Visual Studio .NET to create a Windows-based application. The application includes a
I am working with a WebLogic 10.3.5 clustered environment. My application includes an EJB
I have a WPF application that includes buttons with PNG images. The actual images
i am creating an application which includes dynamic pages. actually, i created some dynamic
I have a C++ application that includes a number of structures with manually controlled
I'm developing a zend framework application that includes a simple email function. The development
I'm writing a drawing application that includes shapes that can have children. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.