Martin, I had used this low level API before (even before 1.5) and I always thought that what I was doing was calling server side with some parameters.... It seems I was wrong. Maybe in a future API split this into a bind and execute?
On Mon, May 16, 2016 at 9:34 AM, Martin Grigorov <[email protected]> wrote: > Hi Ernesto, > > On Sat, May 14, 2016 at 8:59 AM, Ernesto Reinaldo Barreiro < > [email protected]> wrote: > > > Hi Martin, > > > > Thanks for the explanation. To me is a bit weird behavior because I > thought > > > > *Wicket*.*Ajax*.*ajax*({*"u"*:url, e: "click" , *"ep" *: {*'name'*: > name, > > *'type'*: type}, *"pd"*: *true*}); > > > > Meant execute an AJAX call and inform server side about these > parameter.... > > But in reality it mean we are executing the call and at the same time > > binding something that will be executed again on window click... > > > > This is Wicket.Ajax.Call.ajax(attrs) [1]. This is what the bound function > calls whenever the event fires [2]. > The names of these APIs are not very self-explanatory but they are used > since Wicket 1.2 (since Wicket Ajax has been introduced) and I decided to > not break the APIs for Wicket 6.0 (the jQuery introduction). > > 1. > > https://github.com/apache/wicket/blob/76096b7f95586fd3c83f4208c2cc374153fbf884/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L559 > 2. > > https://github.com/apache/wicket/blob/76096b7f95586fd3c83f4208c2cc374153fbf884/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L1979 > > > > > > > On Fri, May 13, 2016 at 9:45 PM, Martin Grigorov <[email protected]> > > wrote: > > > > > HI Ernesto, > > > > > > > > > On Thu, May 12, 2016 at 5:05 PM, Ernesto Reinaldo Barreiro < > > > [email protected]> wrote: > > > > > > > I have a custom component which uses wicket AJAX to call server. > > > > > > > > *MyNameSpace.*SlimTechnologiesLazyListPanel.filter = *function*(url, > > > elem, > > > > event) { > > > > *var *name = *$*(elem).attr(*"techid"*); > > > > *var *type = *$*(elem).attr(*"type"*); > > > > *Wicket*.*Ajax*.*ajax*({*"u"*:url, *"ep" *: {*'name'*: name, > > > *'type'*: > > > > type}, *"pd"*: *true*}); > > > > }; > > > > > > > > I have accidently discovered that if I replace. > > > > > > *Wicket*.*Ajax*.*ajax*({*"u"*:url, *"ep" *: {*'name'*: name, *'type'*: > > > type > > > > }, *"pd"*: *true*}); > > > > > > > > with > > > > > > > > *Wicket*.*Ajax*.*ajax*({*"u"*:url, e: "click" , *"ep" *: {*'name'*: > > > name, > > > > *'type'*: type}, *"pd"*: *true*}); > > > > After this line of code is executed on client then any click you > > perform > > > on > > > > the browser window will issue this AJAX call. Is that the expected > > > > behaviour? > > > > > > > > > > It is expected. > > > To save network traffic all properties have default values. > > > For 'c' (component) the default is the JS window object. So you bind > > > 'click' event listener on the window. > > > For 'e' (event) the default is 'domready'. > > > See > > > > > > > > > https://github.com/apache/wicket/blob/76096b7f95586fd3c83f4208c2cc374153fbf884/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L1947 > > > The rest of the properties are needed after the JS event binding so > they > > > are initialized lazily at > > > > > > > > > https://github.com/apache/wicket/blob/76096b7f95586fd3c83f4208c2cc374153fbf884/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L402 > > > , > > > i.e. after the event is fired. > > > > > > > > > > > > > > -- > > > > Regards - Ernesto Reinaldo Barreiro > > > > > > > > > > > > > > > -- > > Regards - Ernesto Reinaldo Barreiro > > > -- Regards - Ernesto Reinaldo Barreiro
