google-code-export / lwrte

Automatically exported from code.google.com/p/lwrte
1 stars 0 forks source link

can't use regular form post #18

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This plugin replaces the original textarea. 
So it is not possible to use the lwrte with an regular form post, because 
there is no form element (textarea) to post.

It is better to create a hidden field with the original name of the 
original textarea. While changing the content inside the rich text editor, 
the content should be replaced in this hidden field. So I can request the 
modified content on server side from the form post

Original issue reported on code.google.com by juergen....@gmail.com on 2 Mar 2009 at 7:58

GoogleCodeExporter commented 9 years ago
What do you mean 'regular form post'? use lwrte not with textarea?

Original comment by plandem on 5 Mar 2009 at 9:42

GoogleCodeExporter commented 9 years ago
I've tried to post and works perfect.

Original comment by jor...@gmail.com on 8 Mar 2009 at 8:21

GoogleCodeExporter commented 9 years ago
@jordic: I've searched for the textarea with FireBug and I couldn't find the 
original textarea and I can't request the textarea data from the form post.

@plandern: 'regular form post' means to click the submit button in a HTML-Form.

Original comment by juergen....@gmail.com on 8 Mar 2009 at 8:50

GoogleCodeExporter commented 9 years ago
Sure, "original" textarea swapped with iframe at design mode. When user submit 
forms,
then added a hidden field with content of iframe. What's wrong with that? Works 
fine
for me.

Original comment by plandem on 9 Mar 2009 at 3:02

GoogleCodeExporter commented 9 years ago
I do not agree. I have the same problem with my site. I also think it would be 
bether
if you are editing in de design mode that there is a hidden input field for the 
post.

Now it doesn't work because i use a ajax script.

Original comment by 6iinter...@gmail.com on 16 Mar 2009 at 6:17

GoogleCodeExporter commented 9 years ago
Hi @All

>> When user submit forms, then added 
>> a hidden field with content of iframe. 

FireBug says there's no hidden field in the DOM ;-)

Yesterday, I've looked at the JS Code: When user submits the form, the hidden 
field 
should be added (Line 171: "disable_design_mode(false)" should called on form 
submit). 

But that doesn't work for me. The submit starts before the hidden field is 
placed in 
the DOM. I use jQuery 1.3.2. It doesn't work in IE7, neither in FireFox

Original comment by juergen....@gmail.com on 27 Mar 2009 at 9:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Dear plandern,

I also got the same problem. My page loaded thru ajax. Then after I click 
submit, 
the textarea did not submitted to the $_POST variable. the snippets is like 
this...

this page called via ajax call...

script part ...

$(document).ready(function() {

// using validation plugin to validate the form on keyup and submit
var validator = $("#theForm").validate({
    rules: {...},
    messages: {...},
    errorPlacement: function(error, element) {
    },
    submitHandler: function(form) {
        $(form).ajaxSubmit({
            url:        "processform.php",
            type:       "post",
            dataType:   "html",
            success:    function (data) {
            }
        });
    },
    success: function(label) {
    } 
});

var arr = $('.fld_message').rte({
    width: 450,
    height: 200,
    controls_rte: rte_toolbar,
    controls_html: html_toolbar
});

});

html part...

<form id="theForm" name="theForm" autocomplete="off">
<table>
 <tr><td>//some other form element</td></tr>
 <tr>
  <td class="label">
   <label id="lbl_message" for="fld_message">MESSAGE</label>
  </td>
  <td class="field">
   <textarea id="fld_message" name="fld_message" class="fld_message">Some 
text</textarea>*
  </td>
  <td class="status"></td>
 </tr>
 <tr>
  <td class="label"><label class="lbl_submit" for="btn_submit">Submit</label></td>
  <td class="field">
   <input id="btn_submit" name="btn_submit" type="submit" value="Send Email" />
  </td>
 </tr>
</table>
</form>

where did I do wrong? processform.php cannot read $_POST['fld_message'] , the 
script 
works fine when I remove the rte thing. Please help

thanks.

Original comment by azi...@gmail.com on 31 Mar 2009 at 1:58

GoogleCodeExporter commented 9 years ago
Hi, there is form .submit(function(){}) in jquery.rte.js. You make change the 
code
inside and add:

var options= {...}
$(this).ajaxSubmit(options);
return false; 

more info about ajaxSubmit you can find on
http://www.malsup.com/jquery/form/#code-samples

Original comment by kar...@gmail.com on 10 Apr 2009 at 10:29

GoogleCodeExporter commented 9 years ago
HI guys I had the same problem

I was using hte following to submit my form

    $("#savebutton").click(function() {
        var el = $("#page_form");
        el.submit();
    });

a simple change to this worked for me 
    $("#savebutton").click(function() {
        var el = $("#page_form");
        $(".rte").submit();
        el.submit();
    });

the change effectivly tells the .rte elements that they are to consider that a 
submit event is running 

Original comment by spambot....@googlemail.com on 1 Sep 2010 at 2:40

GoogleCodeExporter commented 9 years ago
Hello,

I also had an issue with the form-post. The lwrte is basing on jQuery - so 
jQuery will only catch it's own internal submit-event! This can lead into 
problems if you have pages with mixed-javascript environment (either another 
framework or external scripts that use the usual submit-way of javascript).

I found the following solution, that will re-route the classic-javascript 
submit onto jQuery-Submit. It may not be the ideal solution - but it works fine.

---[ SNIP ]---
  $(document).ready(function() {
    // INIT RTE, grab each RTE using class "wysiwyg"
    $('.wysiwyg').each(function() {        

      // SUBMIT HANDLER
      var $parentForm = $(this).parents("form");
      if(!nativeSubmit) {
        var nativeSubmit = document.forms[ $parentForm.attr('name') ].submit;
      }

      // MAKE JS-SUBMIT ROUTE THROUGH jQUERY-SUBMIT!
      if($parentForm && document.forms[ $parentForm.attr('name') ]) {
        document.forms[ $parentForm.attr('name') ].submit = function() {
          document.forms[ $parentForm.attr('name') ].submit = nativeSubmit;
          $parentForm.trigger("submit");
        }
      }      

      // RTE
      $(this).rte({
        css: ['default.css'],
        controls_rte: rte_toolbar
      });
    });
  });
  )
}
---[ SNAP ]---

Best regards
Gabriel

Original comment by gabriel....@googlemail.com on 14 Jul 2011 at 8:00