PDA

View Full Version : formUpdate



luke83
7 Nov 2006, 6:56 AM
i have this code:

index.htm


App = function(){
[...]
var rmsg = new function(){
this.render = function(el, response){
var obj = response.responseText; // JSON data
alert(obj)
}
}();
[...]
sMsg : function(){
sm=getEl('msg_form').getUpdateManager();
sm.setRenderer(rmsg);
sm.formUpdate("msg_form","msg.php",true);
},
[...]
send (#)

<form id="msg_form" name="msg_form">
<input type="hidden" name="act" value="add"/>
<textarea id="msg_in" name="txt"></textarea>
</form>

<div id="sm"></div>


msg.php:

<?
[...]
echo $_REQUEST['txt'];
?>

what i would?
when a user compile the textarea and click on link "send" it have to pass the field form to msg.php and reset the textarea.
I tried the code above but it didn't work
if i use


sm=getEl('msg_form').getUpdateManager();

the form disappear, load the msg.php page but don't pass the fields to the page

using


sm=getEl('sm').getUpdateManager();

sometime it load the page but didn't reset form

(i'm using .33beta3)

A live demo:
http://impellicment.net/chat[/code]

jack.slocum
7 Nov 2006, 3:13 PM
The UpdateManager is used to update elements. If you set it to update the form, your form gets wiped out. If all you want to do is post a form, just use YAHOO.util.Connect.setForm/asyncRequest. If you want to post the form as an update of a particular HTML element (not the form itself), then use an UpdateManager.

luke83
8 Nov 2006, 1:02 AM
Finally i used YAHOO.util.Connect.setForm/asyncRequest

it works, but only if i don't use tinymce as editor for textarea (turned off, now)
i din't understand what formUpdate do
:roll:

jarrod
9 Nov 2006, 9:13 PM
I've also encountered problems using connect setForm and asyncRequest with TinyMCE...

After some investigation, it seems the problem may not be due to TinyMCE.
It appears that so long as any of the form's input text fields (not necessarily TinyMCE) contain a tag, e.g. '<a>' or similar, the asyncRequest will fail.

Not sure if anyone else has encountered this problem?

---
After more investigation, it turns out that the problem was because I'm submitting the form to a aspx page which by default will block requests with tags.

Fixable by simply adding ValidateRequest="false" to the aspx page.