unbind in jQuery.struts2_jquery

132 views
Skip to first unread message

Joe Huang

unread,
Jun 15, 2011, 11:27:28 PM6/15/11
to struts2-jquery
Hello,

I have a issue here. To be short, I will need to do an unbind or
release the bind after form sumbit:

function _add_image() {
var options_submit = {};
options_submit.jqueryaction = "button";
options_submit.id = "submit_button";
options_submit.targets = "result";
options_submit.href = "#";
options_submit.button = true;
jQuery.struts2_jquery.bind(jQuery('#submit_button'),options_submit);
$('#submit_button').click();
};

I did try
jQuery.struts2_jquery.unbind(jQuery('#submit_button'),options_submit);
and $('#submit_button').unbind(submit_button,options_submit); both not
work. So the question is, if there is a way to release the bind or
unbind in sturst2-jquery?

Here is my reason in long. I have a form to sumbit a sale item
listing. I will need the form to be able to load several images of
the item before the listing can be submit. So, have the AJAX showing
the image thumbnails back after each image is uploaded should do the
job. I have above function added to the onchange event of fileupload.
It works, and the first image uploaded correct and the thumbnail shown
up correctly. However, for the second image the code behavious like
the submit button was clicked twice. the the third image load like the
submit button was clicked three times. I believe the reason is that
"bind" got excused each time and caused this problem. To verify this,
I doubled typed the bind code in the above scripts. Then it acted like
the button was clicked twice for the first image load.

So, to resolve this problem, I will need to have a way to unbind or
release the bind right after "$('#submit_button').click();"

Any suggestion would be appreciated.

Joe

Maitrik Panchal

unread,
Apr 3, 2012, 12:45:17 AM4/3/12
to struts2...@googlegroups.com
Hi Joe,

I'm also stuck with the same problem. I also have the same function which you have given below.
My problem is:
  • I am loading 100s of records through AJAX and all these records generate individual AJAX links on individual onmouseover event.
  • In different AJAX requests, same records are loaded multiple times so it will have same ID which stops link generation if same ID is loaded again with AJAX request.
  • I tried unbind before the bind event on same ID but i duess unbind is not working.
Joe, could you please update this post if u solved this problem with some workaround?
Even any other suggestions will be helpful.

Regards,
Maitrik Panchal

jogep

unread,
Apr 3, 2012, 3:31:06 AM4/3/12
to struts2-jquery
For each AJAX Link or Form Link the Struts2 jQuery Plugin creates an
topic which is published when clicked on the Button or Link.

You need to destroy the topic after first submit.

Forms
jQuery.destroyTopic('_s2j_form_topic_'+<buttonId>);

AJAX Links and Divs

jQuery.destroyTopic('_s2j_div_load_'+<anchorId>);

Also you can enable debug in your head tag.
With debug=true you can see which topics are published
in your Firebug Console or similar tools.

Johannes
---
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep



On Apr 3, 6:45 am, Maitrik Panchal <maitrikgpanc...@gmail.com> wrote:
> Hi Joe,
>
> I'm also stuck with the same problem. I also have the same function which
> you have given below.
> My problem is:
>
>    - I am loading 100s of records through AJAX and all these records
>    generate individual AJAX links on individual onmouseover event.
>    - In different AJAX requests, same records are loaded multiple times so
>    it will have same ID which stops link generation if same ID is loaded again
>    with AJAX request.
>    - I tried unbind before the bind event on same ID but i duess unbind is
> > Joe- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages