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 6120909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:43:25+00:00 2026-05-23T15:43:25+00:00

Complete YUI newbie here. I need to dynamically color text background as user types

  • 0

Complete YUI newbie here.

I need to dynamically color text background as user types the text in the YUI3 text editor control, as follows:

  • First line of the text is orange.
  • All lines until the line that starts with -- are orange.
  • All lines after that, including that with --, until the next one, starting with -- are blue.
  • After that — orange again and so on.

If the first line starts with --, it should be orange nevertheless.

User must not have any manual control on the visual text styles whatsoever, on paste plain text must be inserted and re-colored.

Text background color must be updated in “real” time as user types the text.

Example:

orange orange
orange
orange
-- blue blue 
blue --
blue 
-- orange
-- blue
-- orange orange
orange

Please point me where to start digging on how to implement this. I browsed the examples, but can’t quite grok the stuff yet.

Note: if you know a better suited editor for what I need, for any sane JS framework, please advise.

  • 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-05-23T15:43:26+00:00Added an answer on May 23, 2026 at 3:43 pm

    I think the example you want to look at is the YUI3 nodeChange. For your application you’ll want to be looking for “enter-up” nodeChange events. Then you should be able to use the NodeList from e.dompath to get the proper Node that you want to style. For an example that should get you started, replace the “logFn” function in the example with this:

    var logFn = function(e) {
        Y.log('nodeChange Event: ' + e.changedType);
        if (e.changedType === 'enter-up') {
           var pContainerOfNewBr = e.dompath.item(1);
           var pContainerOfPrevLine = pContainerOfNewBr.previous();
           pContainerOfPrevLine.setStyle('backgroundColor', '#0000ff');
           Y.log('nodeChange got enter-up: ' + e.changedType);
        }
    };
    

    And change the “on” listener to an “after”.

    editor.after('nodeChange', logFn);
    

    What you should see from this is that after you hit “enter” on a line, the background-color of the previous line should turn blue. Not exactly what you want but hopefully in the right direction.

    Caveat — the Rich Text Editor is a pretty complex Widget to be diving into for your first YUI3 experience. It will be easier if you get a good handle on YUI3 Events and Nodes, though you’ll probably be quite challenged if you need to hack the actual RTE code.

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

Sidebar

Related Questions

Complete CSS newbie here who just applied the image resizing trick in the accepted
Complete newbie question here: I'm just playing with C# for the first time and
Complete Haskell newbie here, my apologies.... I am trying to create a sequence of
Complete C# newbie here, so cut me some slack. I have this application that
Complete LaTeX and LyX newbie here. I am currently writing a document in LyX
complete noob to Haskell here with probably an even noobier question. I'm trying to
To complete some testing I need to load the 64 bit version of an
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
Complete novice question. I've used jQuery a bit, YUI not at all and know
complete newb quesiton here, but I'm new to C# and Visual Studio 2010. How

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.