Is it possible to have an anchor submit the surrounding ajax form
without explicitly knowing the form's id?
In my template I have a bunch of <a> tags that needs to submit the
ajax form (serializing checkboxes in this case) and then return with
some content. I basically want the SHtml.ajaxSubmit:
def ajaxSubmit(value: String, func: () => JsCmd, attrs: ElemAttr*): Elem = {
val funcName = "z" + Helpers.nextFuncName
addFunctionMap(funcName, contextFuncBuilder(func))
(attrs.foldLeft(<input type="submit" name={funcName}/>)(_ % _)) %
new UnprefixedAttribute("value", Text(value), Null) %
("onclick" -> ("liftAjax.lift_uriSuffix = '"+funcName+"=_';
return true;"))
}
but tied to the onclick of an anchor instead of an actual submit. The
alternatives I can find needs the id of the form:
def submitAjaxForm(formId: String, func: () => JsCmd): JsCmd
Unfortunately I can't control the id of the form when I use lift:form.
I guess that's just the way it is. Or is there some smart thing I
could do to get around this?
I know I should probably just bind the anchors to submits and then
style those to look the same, but I thought I should ask… :) Also I
can see a use case where random js would want to perform a submit of
the ajax form…?
Thanks,
Viktor
This might be kind of a stupid web-newbie question…
Is it possible to have an anchor submit the surrounding ajax form
without explicitly knowing the form's id?
In my template I have a bunch of <a> tags that needs to submit the
ajax form (serializing checkboxes in this case) and then return with
some content. I basically want the SHtml.ajaxSubmit:
def ajaxSubmit(value: String, func: () => JsCmd, attrs: ElemAttr*): Elem = {
val funcName = "z" + Helpers.nextFuncName
addFunctionMap(funcName, contextFuncBuilder(func))
(attrs.foldLeft(<input type="submit" name={funcName}/>)(_ % _)) %
new UnprefixedAttribute("value", Text(value), Null) %
("onclick" -> ("liftAjax.lift_uriSuffix = '"+funcName+"=_';
return true;"))
}
but tied to the onclick of an anchor instead of an actual submit. The
alternatives I can find needs the id of the form:
def submitAjaxForm(formId: String, func: () => JsCmd): JsCmd
Unfortunately I can't control the id of the form when I use lift:form.
I guess that's just the way it is. Or is there some smart thing I
could do to get around this?
I know I should probably just bind the anchors to submits and then
style those to look the same, but I thought I should ask… :) Also I
can see a use case where random js would want to perform a submit of
the ajax form…?
Thanks,
Viktor
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Thanks for the suggestion! In this particular case I actually grabbed
myself in the neck, screamed "a little css ain't gonna kill you" into
my ear and used buttons instead.
> Did you open a ticket for getting the id AjaxForm (or was that Lukasz?)
No, wasn't me. Found one ticket that that asked for the possibility to
manually set the form id though, but I guess that was problematic:
https://groups.google.com/forum/#!searchin/liftweb/merge$20form$20id/liftweb/8mBndo6S1Fo/QEtwSAMppaUJ
https://www.assembla.com/spaces/liftweb/tickets/624-merge-form-ids
Cheers,
Viktor