How to make an SHTML.ajaxSubmit button with the HTML's original button label instead of parameter

39 views
Skip to first unread message

DoomPirate

unread,
Feb 3, 2016, 11:00:11 PM2/3/16
to Lift
Hi,

My question is:
How do I create an ajax submit button without overwriting the button's original label from the template html.

I am using ajax buttons for my form.
".action" #> SHtml.ajaxSubmit("I hope this text doesn't show", process ) 

Which runs the "process" function whenever clicking the button.
I want the template's label, not the ajaxSumbit's button label.

For my use case, it is quite important for me to be able to use the template's label, not the one that ajaxSubmit writes onto the button.

Thanks,
Phil

Andreas Voeth

unread,
Feb 4, 2016, 1:32:56 AM2/4/16
to Lift
Hi Phil,

as its about 5am here its going to be a short answer.

You could bind a function "NodeSeq => NodeSeq" which extracts the label
from the given NodeSeq. It should look like this:

".action" #> { n : NodeSeq => SHtml.ajaxSubmit(extractLabel(n), process) }

...

def extractLabel(n : NodeSeq) : String = ???

I know I have code here for exactly this purpose but just can't find it
right now and won't be able to search until in about 20 hours. But this
should give you the idea.

Andreas

Matt Farmer

unread,
Feb 4, 2016, 8:58:56 AM2/4/16
to lif...@googlegroups.com
Phil,

I'm on my phone so I can't go into details. But take a look at ajaxOnSubmit


Matt Farmer Blog | Twitter
GPG: CD57 2E26 F60C 0A61 E6D8  FC72 4493 8917 D667 4D07
--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

DoomPirate

unread,
Feb 4, 2016, 11:44:19 AM2/4/16
to Lift
Thanks Matt and Andreas, this worked.
".action" #> SHTML.ajaxOnSubmit(process)

Antonio Salazar Cardozo

unread,
Feb 4, 2016, 1:12:22 PM2/4/16
to Lift
Yep, nailed it. We added ajaxOnSubmit for exactly that purpose :)
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages