Jump to content

Hook into a div with a class or id name


Danjuan09
 Share

Recommended Posts

Hi

I'm making my first module and i'm trying to add contenteditable='true' to a div so that

<div class="container"></div>

becomes

<div class="container" contenteditable='true'></div>

I've been trying 

$event->return = str_replace("</div class'container'>", $edit."</body>", $event->return);

but that won't work

Link to comment
Share on other sites

This might be easiest using jquery which you can do quite easily from your module also.

Looking at your str_replace, I don't really get it. Wouldn't you want:

$event->return = str_replace('<div class="container">', '<div class="container" contenteditable='true'>', $event->return);

But that said, I think jquery might be easier:

$('.container').attr('contenteditable', 'true');

Otherwise, you might want to consider domdocument to modify it in PHP if you need to do it server side - it really depends on whether you can guarantee the exact structure of that container div.

Have you tested that the $event->return is actually being implemented in the first place? Have you looked at the: $event->replace = true; option?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...