Danjuan09 Posted December 19, 2014 Share Posted December 19, 2014 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 More sharing options...
adrian Posted December 19, 2014 Share Posted December 19, 2014 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? 1 Link to comment Share on other sites More sharing options...
Danjuan09 Posted December 19, 2014 Author Share Posted December 19, 2014 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 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now