Passing arguments to callback function
I everyone, in our app we have many JavaScript/JQuery libraries for handling "domains". The libraries of course use functions and we bind these functions to events with JQuery.
But now, I want to pass arguments to some of these functions but passing arguments to functions with brackets execute the function on page loading..
To be more concrete, I have this library :
- var Articles = {
- addReaction : function(event) {
- event.preventDefault();
- $.wait();
- $.get(CONTEXT+'ui/parts/articles/addreaction.html', function(fragment) {
- var $link = $(event.target);
- var $form = $(fragment).insertAfter($link).makeAjaxForm($link.parent())
- .find('input[type="reset"]').click(function(){
- alert("Removing "+$form)
- $form.remove();
- }).end();
- });
- $.unblockUI();
- }
- };
And I use it like that :
- $(document).ready(function(){
- // jqn is an utility function to escape dots
- // FIXME give the article id to Articles.addReaction
- $(jqn('#lnk.addreaction')).click(Articles.addReaction);
- });
This code work fine but I want to pass a number (the article id) to the "
Articles.addReaction" function. And I don't know how to do that.
Thanks