Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31370 > unrolled thread

event listener behavior different in ie chrome

Started byAndrew <andrew.m.levin.1@gmail.com>
First post2016-09-14 06:14 -0700
Last post2016-09-15 08:16 +0200
Articles 7 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  event listener behavior different in ie chrome Andrew <andrew.m.levin.1@gmail.com> - 2016-09-14 06:14 -0700
    Re: event listener behavior different in ie chrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-14 15:00 +0100
      Re: event listener behavior different in ie chrome Andrew <andrew.m.levin.1@gmail.com> - 2016-09-14 07:13 -0700
        Re: event listener behavior different in ie chrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-14 19:46 +0100
          Re: event listener behavior different in ie chrome Andrew <andrew.m.levin.1@gmail.com> - 2016-09-14 11:53 -0700
            Re: event listener behavior different in ie chrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-09-15 01:09 +0100
        Re: event listener behavior different in ie chrome Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2016-09-15 08:16 +0200

#31370 — event listener behavior different in ie chrome

FromAndrew <andrew.m.levin.1@gmail.com>
Date2016-09-14 06:14 -0700
Subjectevent listener behavior different in ie chrome
Message-ID<f56b7236-7009-4a5a-b50c-a8c8ff3f5769@googlegroups.com>
Hi,

I found that the following 

add_message_form.addEventListener('submit', function (e) {                                                                                                                                                                                                                                                                    
                                                                                                                                                                          
e.preventDefault();                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
add_message_form.submit();                                                                                                                                                
                                                                                                                                                                                                                                                                                                                              
add_message_form.reset();                                                                                                                                                                                                                                                                                                                                                                                                                                                    

}, false)           

triggers different behavior in chrome and ie. In chrome the reset is performed before the submit and in ie the submit is performed before the reset. To me it seems that the ie behavior is the correct one. Does anyone understand what is going on?

Thanks.

Andrew

[toc] | [next] | [standalone]


#31371

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-09-14 15:00 +0100
Message-ID<87bmzqoa2h.fsf@bsb.me.uk>
In reply to#31370
Andrew <andrew.m.levin.1@gmail.com> writes:

> I found that the following 
>
> add_message_form.addEventListener('submit', function (e) {
>                                                                                                                                                                           
> e.preventDefault();
>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
> add_message_form.submit();
>                                                                                                                                                                                                                                                                                                                               
> add_message_form.reset();
>
> }, false)

Why all the newlines and spaces?

> triggers different behavior in chrome and ie. In chrome the reset is
> performed before the submit and in ie the submit is performed before
> the reset. To me it seems that the ie behavior is the correct
> one. Does anyone understand what is going on?

Calling submit does not guarantee that the form's content will be
collected then and there.  What I suspect you are seeing is that the
form is submitted when the browser "has a moment" and this happens to be
after the reset has been done.

Whatever you are trying to do, you will have to find some other way to
do it.  What is the overall objective?

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#31372

FromAndrew <andrew.m.levin.1@gmail.com>
Date2016-09-14 07:13 -0700
Message-ID<59b6ef73-5015-49ac-97a5-431e16a3282b@googlegroups.com>
In reply to#31371
On Wednesday, September 14, 2016 at 4:00:47 PM UTC+2, Ben Bacarisse wrote:
> Andrew <*@gmail.com> writes:
> 
> > I found that the following 
> >
> > add_message_form.addEventListener('submit', function (e) {
> >                                                                                                                                                                           
> > e.preventDefault();
> >                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
> > add_message_form.submit();
> >                                                                                                                                                                                                                                                                                                                               
> > add_message_form.reset();
> >
> > }, false)
> 
> Why all the newlines and spaces?
> 
> > triggers different behavior in chrome and ie. In chrome the reset is
> > performed before the submit and in ie the submit is performed before
> > the reset. To me it seems that the ie behavior is the correct
> > one. Does anyone understand what is going on?
> 
> Calling submit does not guarantee that the form's content will be
> collected then and there.  What I suspect you are seeing is that the
> form is submitted when the browser "has a moment" and this happens to be
> after the reset has been done.
> 
> Whatever you are trying to do, you will have to find some other way to
> do it.  What is the overall objective?
> 
> -- 
> Ben.

Hi Ben,

I would like to submit the form then reset the form (so that the submitted form is not empty). How can I guarantee that the submit and the reset are performed in the order that I want them to be performed?

Thanks.

Andrew

[toc] | [prev] | [next] | [standalone]


#31374

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-09-14 19:46 +0100
Message-ID<87zinami9x.fsf@bsb.me.uk>
In reply to#31372
Andrew <andrew.m.levin.1@gmail.com> writes:

> On Wednesday, September 14, 2016 at 4:00:47 PM UTC+2, Ben Bacarisse wrote:
<snip>
>> ...  What is the overall objective?
<snip>
> I would like to submit the form then reset the form (so that the
> submitted form is not empty). How can I guarantee that the submit and
> the reset are performed in the order that I want them to be performed?

This is not your overall goal.  That's just what the code tries to do
written out in English -- i.e. there's no new information here.

I don't know any way to help you do what you want without more
information.  The details depend on too many things left unspecified.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#31375

FromAndrew <andrew.m.levin.1@gmail.com>
Date2016-09-14 11:53 -0700
Message-ID<d44e9c5d-55d6-4471-bec4-e7075aca07aa@googlegroups.com>
In reply to#31374
On Wednesday, September 14, 2016 at 8:46:27 PM UTC+2, Ben Bacarisse wrote:
> Andrew <*@gmail.com> writes:
> 
> > On Wednesday, September 14, 2016 at 4:00:47 PM UTC+2, Ben Bacarisse wrote:
> <snip>
> >> ...  What is the overall objective?
> <snip>
> > I would like to submit the form then reset the form (so that the
> > submitted form is not empty). How can I guarantee that the submit and
> > the reset are performed in the order that I want them to be performed?
> 
> This is not your overall goal.  That's just what the code tries to do
> written out in English -- i.e. there's no new information here.
> 
> I don't know any way to help you do what you want without more
> information.  The details depend on too many things left unspecified.
> 
> -- 
> Ben.

Hi Ben,

I have a form with a text box in it:

 <form id="add_message_form" target="console_iframe1" method="post" action="add_message">                                                                                 
  <input type="text" id="message" name="message" size="100" /> <br> <br>                                                                                                  
  </form>                                                                                                                                                                 

I would like the following to happen when the user presses enter in the text box.

1) The form will be submitted.

2) The text in the text box will disappear.

Obviously, I want the form to be submitted with a nonempty text box value.

Andrew

[toc] | [prev] | [next] | [standalone]


#31376

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-09-15 01:09 +0100
Message-ID<87oa3qm3b0.fsf@bsb.me.uk>
In reply to#31375
Andrew <andrew.m.levin.1@gmail.com> writes:

> On Wednesday, September 14, 2016 at 8:46:27 PM UTC+2, Ben Bacarisse wrote:
>> Andrew <*@gmail.com> writes:
>> 
>> > On Wednesday, September 14, 2016 at 4:00:47 PM UTC+2, Ben Bacarisse wrote:
>> <snip>
>> >> ...  What is the overall objective?
>> <snip>
>> > I would like to submit the form then reset the form (so that the
>> > submitted form is not empty). How can I guarantee that the submit and
>> > the reset are performed in the order that I want them to be performed?
>> 
>> This is not your overall goal.  That's just what the code tries to do
>> written out in English -- i.e. there's no new information here.
>> 
>> I don't know any way to help you do what you want without more
>> information.  The details depend on too many things left unspecified.
>
> Hi Ben,
>
> I have a form with a text box in it:
>
>  <form id="add_message_form" target="console_iframe1" method="post" action="add_message">                                                                                 
>   <input type="text" id="message" name="message" size="100" /> <br> <br>                                                                                                  
>   </form>                                                                                                                                                                 
>
> I would like the following to happen when the user presses enter in the text box.
>
> 1) The form will be submitted.
>
> 2) The text in the text box will disappear.
>
> Obviously, I want the form to be submitted with a nonempty text box
> value.

I think you will have listen for the the iframe being loaded and reset
the form on that event.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#31377

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2016-09-15 08:16 +0200
Message-ID<b2ce$57da3cad$6def49cc$14820@nntpswitch.blueworldhosting.com>
In reply to#31372
On 14/09/2016 16:13, Andrew wrote:
> On Wednesday, September 14, 2016 at 4:00:47 PM UTC+2, Ben Bacarisse
> wrote:
>> Andrew <*@gmail.com> writes:
>>
>>> I found that the following
>>>
>>> add_message_form.addEventListener('submit', function (e) {
>>>
>>> e.preventDefault();
>>>
>>> add_message_form.submit();
>>>
>>> add_message_form.reset();
>>>
>>> }, false)
>>
>> Why all the newlines and spaces?
>>
>>> triggers different behavior in chrome and ie. In chrome the reset
>>> is performed before the submit and in ie the submit is performed
>>> before the reset. To me it seems that the ie behavior is the
>>> correct one. Does anyone understand what is going on?
>>
>> Calling submit does not guarantee that the form's content will be
>> collected then and there.  What I suspect you are seeing is that
>> the form is submitted when the browser "has a moment" and this
>> happens to be after the reset has been done.
>>
>> Whatever you are trying to do, you will have to find some other way
>> to do it.  What is the overall objective?
>>
>> -- Ben.
>
> Hi Ben,
>
> I would like to submit the form then reset the form (so that the
> submitted form is not empty). How can I guarantee that the submit and
> the reset are performed in the order that I want them to be
> performed?

I'd rather wait until server respond and then, if success, then reset 
the form. Otherwise show the error message and leave the form not cleared.

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web