error after first AJAX call

View: New views
2 Messages — Rating Filter:   Alert me  

error after first AJAX call

by alemaj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello!
I'm relatively new in developing with Behaviour and I have a problem
using Struts.

My problem is that the first time I execute my code all is working
correctly.
I have a combo and when the value selected changes an AJAX call starts
and reload part of my JSP,
the part where I have the combobox.
After the reloading of the page my combo doesn't react when I change
its value.
It seems not to be linked to the onchange function.

My code is like this:


File tipoCID.js

var TipoCID = {
                'select.CID': function(el){
                        el.onchange = function(){
                                calculateSottoTipoCID(el.name, el.value);
                        }
                }
        }

        function calculateSottoTipoCID(id, value){
                var myAjax = new Ajax.Updater(
                        {success: 'importi'},
                        'sottotipoCID.do',
                        { method: 'post', parameters: Form.serialize('riservaForm')+
'&id='+ id + '&value=' +value}
                );
        }



JSP:

<script src="js/tipoCID.js" type="text/javascript"
language="javascript" charset="utf-8"></script>


<div id="importi">
...
<select class="CID" name = "name"/>
...
</div>

Behaviour.register(TipoCID);

Note that in the Struts Action I modify some data and then they are
reload correctly inside the div block.
My only problem is that my combo hasn't the onchange function
associated once I execute for the first time an AJAX call!

Does anybody can help me telling me what's wrong here?

Thank you.
Ale



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group.
To post to this group, send email to behaviour@...
To unsubscribe from this group, send email to behaviour-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/behaviour?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: error after first AJAX call

by Jakob Kruse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Alemaj,

You need to reapply the sheet after you change the DOM (which you do
when you run an Ajax.Updater).

I recommend you update to my version 1.2 of Behaviour, available from
http://www.kruse-net.dk/behaviour/, and then call applySheet(TipoCID)
from the onSuccess or onComplete handler of your Ajax.Updater.

Regards,
Jakob


On Dec 4, 3:47 pm, alemaj <alessandro.maj...@...> wrote:

> Hello!
> I'm relatively new in developing with Behaviour and I have a problem
> using Struts.
>
> My problem is that the first time I execute my code all is working
> correctly.
> I have a combo and when the value selected changes an AJAX call starts
> and reload part of my JSP,
> the part where I have the combobox.
> After the reloading of the page my combo doesn't react when I change
> its value.
> It seems not to be linked to the onchange function.
>
> My code is like this:
>
> File tipoCID.js
>
> var TipoCID = {
>                 'select.CID': function(el){
>                         el.onchange = function(){
>                                 calculateSottoTipoCID(el.name, el.value);
>                         }
>                 }
>         }
>
>         function calculateSottoTipoCID(id, value){
>                 var myAjax = new Ajax.Updater(
>                         {success: 'importi'},
>                         'sottotipoCID.do',
>                         { method: 'post', parameters: Form.serialize('riservaForm')+
> '&id='+ id + '&value=' +value}
>                 );
>         }
>
> JSP:
>
> <script src="js/tipoCID.js" type="text/javascript"
> language="javascript" charset="utf-8"></script>
>
> <div id="importi">
> ...
> <select class="CID" name = "name"/>
> ...
> </div>
>
> Behaviour.register(TipoCID);
>
> Note that in the Struts Action I modify some data and then they are
> reload correctly inside the div block.
> My only problem is that my combo hasn't the onchange function
> associated once I execute for the first time an AJAX call!
>
> Does anybody can help me telling me what's wrong here?
>
> Thank you.
> Ale
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Behaviour Javascript Library" group.
To post to this group, send email to behaviour@...
To unsubscribe from this group, send email to behaviour-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/behaviour?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price