I don't think i can pull a small example from here because I'm
combining my lack of knowledge in scala, lift, html, jquery,
tinyMCE ....... you get the idea.

The point is that I am trying to create a button that calls a scala
function and a javascript function.  I am currently trying to use an
shtml.ajaxButton, though I don't know if that is the right tool.

Button:
           "save1" -> SHtml.ajaxButton(
             "Fixed",
              { () => {
                println("Fixed scala/lift.");
                saveClaimStatus("FIXED");   //scala function.  works
as intended
                JsRaw("$.saveT();").cmd);
                }
              })


javascript function:
       function saveT () {
            document.form[0].submit();
        };

In the 42 different ways I have tried to implement this, I can get one
or the other to function, but i cannot get both to work.

How do I do both functions with one button?

Thanks.  And I'm sorry if I'm not explaining this correctly, or that
it's not making much sense.

-Chris



On Oct 20, 2:31 pm, Marius <marius.dan...@gmail.com> wrote:
> I was hoping to see something minimalistic and isolated so I can
> quickly try it out.
>
> I'm not sure what you do with redirect("/workflow/claims")  but from
> Ajax function you should probably use JsCmd.RedirectTo ..
>
> Hopefully I'll have some time this weekend to play with tinyMCE
>
> Br's,
> Marius
>
> On Oct 19, 10:57 pm, caw1461 <caw1...@gmail.com> wrote:
>
> > edit.html:
>
> >     <script type="text/javascript">
>
> >     tinyMCE.init({
> >         // General options
> >         mode : "textareas",
> >         theme : "advanced",
> >         plugins :
> > "spellchecker,pagebreak,save,advhr,advimage,advlink,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
> >         theme_advanced_buttons1 :
> > "styleselect,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,
> > hr, bullist,numlist, preview, code",
> >         theme_advanced_buttons2 : "",
> >         theme_advanced_buttons3 : "",
> >         theme_advanced_buttons4 : "",
>
> >         submit_patch : false,
>
> >         theme_advanced_resizing : true
> >     });
>
> >     // The save function that actually works.
>
> >     $.saveFunc = function() { tinyMCE.activeEditor.save() };
>
> >     function saveT () {
> >         console.log("javascriptconsole 1")
> >         tinyMCE.activeEditor.save()
> >         console.log("javascriptconsole 2")
> >     };
>
> >     $('#fixed').click(function(e){
> >         tinyMCE.activeEditor.save()
> >     });
> >     </script>
>
> >     <editor:text/>
> >     <br/>
>
> >     <!--  NOW WORKS CORRECTLY -->
> >     <button id="Save" onclick="saveT()" class="ui-state-default"
> > title="Save, only save the html, doesn't mark the claim ready for
> > publishging.">Save</button>
>
> >     <editor:save1/>
> >     <editor:cancel/>
> >     <editor:save2/>
>
> > //////////////*********************************//////////////////////
>
> > Workflow.scala:
>
> >   SHtml.ajaxForm(
> >         bind("editor", xhtml,
>
> >             "text" -> SHtml.textarea(originalOrEditedFileAsString
> > (selectedClaimWorkQueue.open_!.fileName),
> >                 s => {
> >                     println(s)
> >                     saveClaimHtmlToDB(s)
> >                     saveClaimHtml(s,
> > selectedClaimWorkQueue.open_!.fileName)
> >                     S.notice("Submitted.")
> >                     redirect("/workflow/claims")
> >                 } , ("style", "height: 500px; width:97%"), ("id",
> > "mceForm")),
>
> >            "save" -> SHtml.ajaxButton(
> >              "Save",
> >              {() =>
> >                Log.info("Got a 'save' AJAX call")
> >               saveClaimStatus("EDITED")
> >               S.notice("Saved.")
> >               redirect("/workflow/claims")
> >             }, ("type", "submit"),("class", "ui-state-default "),
> > ("title", "Save, only save the html, does not mark the claim ready for
> > publishging."), ("id", "fixed")),
> >            "save1" -> SHtml.ajaxButton(
>
> >              "Fixed",
> >               { () => {
> >                 println("Fixed scala/lift.");
> >                 saveClaimStatus("FIXED");
> >                 JsRaw("$.saveFunc();").cmd);
> >                 }
> >               }, ("class", "ui-state-default "), ("title", "Save and
> > marks the claim ready for publishing."), ("id", "fixed")),
> >             "save2" -> SHtml.ajaxButton(
> >                 "yes", () => {JsRaw("$.saveFunc();").cmd })))
>
> >     }
>
> > I'm already importing both of those so that isn't the problem.  If I
> > put a % ("onclick" -> "saveT()") on the button, it saves the way I
> > want it to, but it does not do any of the println or saveClaimStatus
> > calls.  I just want it to do both.
>
> > On Oct 19, 3:43 pm, Marius <marius.dan...@gmail.com> wrote:
>
> > > I think with an
>
> > > import net.liftweb.http.js._
> > > import JsCmds._
>
> > > the compile problem should go away as there is an implicit defined
> > > there. But this is not important.
>
> > > Can you send a minimalistic code example that reflects the
> > > problem? ... including the template and Scala code.
>
> > > Br's,
> > > Marius
>
> > > On Oct 19, 9:48 pm, caw1461 <caw1...@gmail.com> wrote:
>
> > > > My saveClaimSatus("") function saves the passed value to the
> > > > database.
> > > > Firebug is not giving me any errors and prints the line to the
> > > > console.
>
> > > > The order in which the two updates happen is important because I need
> > > > the status updated before the form is saved.
>
> > > > I am using two different versions of saving to keep a temporary "save"
> > > > and then a finalized "For Publish" version.
>
> > > > so I need both of them to save the form, which i was trying to use the
> > > > saveFunc to do.
>
> > > > and removing the .cmd seems to give a syntax errors:
>
> > > > E:\patentTracker3\prospective_claims_ver_br\patentTrackerUi\src\main
> > > > \scala\com\trlr\binpr\snippet\Workflow.scala:473: error: overloaded
> > > > method valueajaxButtonwith alternatives (String,() =>
> > > > net.liftweb.http.js.JsCmd,(String, String)*)scala.xml.Elem <and>
> > > > (scala.xml.NodeSeq,() => net.liftweb.http.js.JsCmd,(String, String)*)
> > > > scala.xml.Elem cannot be applied to (java.lang.String,() =>
> > > > net.liftweb.http.js.JE.JsRaw,(java.lang.String, java.lang.String),
> > > > (java.lang.String, java.lang.String),(java.lang.String,
> > > > java.lang.String))
> > > >            "save1" -> SHtml.ajaxButton(
>
> > > > On Oct 19, 2:20 pm, Marius <marius.dan...@gmail.com> wrote:
>
> > > > > I think you can simply return  JsRaw("$.saveFunc();") without using
> > > > > JsRaw("$.saveFunc();").cmd
>
> > > > > Do you see any errors in the browser? ... try using firebug addon in
> > > > > firefox and see if it complains about anything. What does
> > > > > saveClaimStatus("EDITED") do?
>
> > > > > Regarding "I'm just trying to run ajavascriptfunction followed by my
> > > > > saveClaimStatus("EDITED") function. " ... when you press thebutton
> > > > > thatajaxfunction on the server side gets executed and it returns 
> > > > > aJavaScriptback to browser where $.saveFunc() suppose to be executed.
> > > > > In your code saveClaimStatus is run before running  $saveFunc() in the
> > > > > case of the save1buttonwhich seems to be the other way around. What
> > > > > is your actual use case?
>
> > > > > Br's,
> > > > > Marius
>
> > > > > On Oct 19, 8:29 pm, caw1461 <caw1...@gmail.com> wrote:
>
> > > > > > I figured this was a simple problem, but have spent way too much 
> > > > > > time
> > > > > > on this issue.
>
> > > > > >     $.saveFunc   = function() { saveT(); };
>
> > > > > >     function saveT () {
> > > > > >         print("save function executing")
> > > > > >         tinyMCE.activeEditor.save()
> > > > > >         print("save completed")
> > > > > >     };
>
> > > > > >     <buttonid="Save" onclick="saveT()" class="ui-state-default"
> > > > > > title="Save, only save the html, doesn't mark the claim ready for
> > > > > > publishging.">Save</button>
>
> > > > > > as a purejavascript/html, this works as intended, thebuttonsaves/
> > > > > > submits the form.
>
> > > > > >            "save1" -> SHtml.ajaxButton(
> > > > > >              "Fixed",
> > > > > >              {
> > > > > >                () => {
> > > > > >                 println("Jenn is on crack.");
> > > > > >                 saveClaimStatus("EDITED")
> > > > > >                 JsRaw("$.saveFunc();").cmd;
> > > > > >                 }
> > > > > >              }, ("class", "ui-state-default "), ("title", "Save and
> > > > > > marks the claim ready for publishing."), ("id", "fixed")),
> > > > > >             "save2" -> SHtml.ajaxButton(
> > > > > >                 "yes",
> > > > > >                   () => {println("Rhode Island Destroyed")
> > > > > >                          JsRaw("$.saveFunc();").cmd})
>
> > > > > > I used your example in the other thread aboutajaxbuttonand
> > > > > >javascript, but I can't get the functionality I am looking for.
>
> > > > > > save2 is just a testbuttonto check functionality.  It does run the
> > > > > > println, but it does not run the saveT function.
>
> > > > > > 13:19:17.725 [29569...@qtp-6966554-8] DEBUG comet_trace.debug:82 -
> > > > > >AJAXRequest: 182kyt8t8rjdz Map(F527240256671NZ2 -> List(true))
> > > > > > Rhode Island Destroyed
> > > > > > 13:19:17.725 [29569...@qtp-6966554-8] DEBUG comet_trace.debug:82 -
> > > > > >AJAXResponse: 182kyt8t8rjdz InMemoryResponse(
> > > > > > $.saveFunc();;, List((Content-Length,15), (Content-Type,text/
> > > > > >javascript; charset=utf-8)), List(), 200)
>
> > > > > > I'm just trying to run ajavascriptfunction followed by my
> > > > > > saveClaimStatus("EDITED") function.
>
> > > > > > I just think i'm either not going about this correctly or not
> > > > > > understanding my problem correctly.
>
> > > > > > Any help would be a godsend.
>
> > > > > > Thanks,
>
> > > > > > Christopher
>
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to