I agree. Allowing for a "guard" JavaScript expression to be called before the Ajax call is made would be nice.
Derek On Tue, Apr 28, 2009 at 3:02 PM, marius d. <marius.dan...@gmail.com> wrote: > > Pretty much all SHtml function related to Ajax invokes the ajax call > as to click the link, button, etc. SHtml.ajaxCall function allow you > to provide a JsExp (which could be any JavScript expression) who's > result would be passed to the ajax call. But I don't think this will > help your case a whole lot. > > Maybe we can do another SHtml helper that would help your case. Such > as: > > > 1. On click, we are calling a user defined Ajax function and pass to > it a function that does the actual Ajax call > 2 In your JS function (which would be the confirm function) you can > choose to call the function passed whenever you want, so you'd have > the liberty to actually do the ajax request or not. > > Of course you could implement this yourself quite easily but I think > it worth having something like that in SHtml for a simpler use. > > Looks to me that this would be a nice addition to SHtml. > > Br's, > Marius > > On Apr 28, 3:48 am, Chris <cfor...@gmail.com> wrote: > > Hi Tim, > > just one addition. Wicket has something called an ajaxcall decorator > > (IAjaxCallDecorator) that allows you to modify the script and more > > specifically the "decorateScript" method allows you to prepend a char- > > sequence to the script. This would allow me to do exactly what I want. > > Is there any way in Lift to achieve the same thing? I'd really like to > > avoid dealing with JavaScript directly apart from something as trivial > > as the "confirm(...)" dialog or similar. > > Cheers, Chris. > > > > On Apr 28, 9:56 am, Chris <cfor...@gmail.com> wrote: > > > > > Hi Tim, > > > not sure if I really got across what I need. I need the AJAX > > > functionality in this case as I'm displaying a large amount of data in > > > a table and would like to allow the user to delete individual records > > > without the refresh problem of having the button cause a POST. I also > > > need to make sure the user hasn't "accidentally" pressed "delete", > > > hence the "confirm(..)" dialog. Does option (1) above prevent the > > > subsequent call of the ajaxButton if the user presses "cancel" on the > > > JS "confirm" dialog, but allow it if he presses "OK"? Option (2) is > > > just a slightly different way of doing what I've already tried (I > > > added the "onclick" attribute to the ajaxButton call itself) and this > > > subsequently removes the actual AJAX call itself. > > > Thanks, Chris. > > > > > On Apr 28, 9:22 am, Timothy Perrett <timo...@getintheloop.eu> wrote: > > > > > > Hey, > > > > > > Seems like you have a couple of options... > > > > > > 1. you could just write normal javascript irrespective of lift and > > > > just put that in a JS file like normal. Something like: > > > > > > $('#mybutton').click(function(e){ > > > > confirm... //blah blah code here > > > > > > }); > > > > > > 2. If you *really* want to use the on-click handler (personally I > > > > wouldn't) then you could do somethig like this in your snippet: > > > > > > SHtml.ajaxButton("submit", () => println("badger")) % ("onclick" -> > > > > "confirm(....);") > > > > > > I would highly recommend using option one as the functionality is > > > > purely a client side concern in that sense and nothing to do with > > > > lift. Does that help? > > > > > > Cheers, Tim > > > > > > On Apr 27, 11:29 pm, Chris <cfor...@gmail.com> wrote: > > > > > > > Hi there, > > > > > I'm pretty new to Lift and Scala for that matter, but have long > been > > > > > on the lookout for something like seaside running on the JVM and > this > > > > > is just great! Now to my issue... > > > > > I've hit a brick-wall in the attempt to get a confirmation dialog > > > > > working before executing an ajaxButton. I've tried adding an > "onclick" > > > > > attribute to the ajaxButton call, but that only seems to replace > the > > > > > AJAX call itself rather than say prepending the call with the > contents > > > > > of the "onclick" attribute. I'd like to implement a "delete" button > > > > > with a confirmation dialog. I've looked at ModalDialog, but due to > my > > > > > inexperience and lack of examples haven't found a way of achieving > > > > > this. Could someone enlighten me as to how I could implement this? > > > > > Cheers, Chris. > > > > > PS: I hope this isn't a FAQ but I've searched this group and the > web > > > > > on the matter, but haven't found an answer, so sorry in advance if > > > > > this has been answered before. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---