Jump to content

Recommended Posts

Posted

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

Posted

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
Posted

Hi Adrian

Can't believe I missed the query way, schoolboy error. I think I was too wrapped up in process wire to even think properly.

Your jquery suggestion works a treat.

Thanks

  • Like 1

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
  • Recently Browsing   0 members

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