Note that there are some explanatory texts on larger screens.

plurals
  1. POliftweb notice/message/warning does not work for the second time
    primarykey
    data
    text
    <p>I am trying to display validation messages in an app built using <code>liftweb 2.4</code> scala web framework.<br> The app has only one text box and submit button to add the text to db. On submit the snippet code checks whether the text box is empty and displays a message. </p> <pre><code> package snippet { object Notes { def noteForm(in: NodeSeq): NodeSeq = { def add() = { if (note.description.isEmpty()) { S.error("descError", "Please enter a note") } else { note.save NotesServer ! "refresh" S.notice("descMessage", "Note added.") } } bind("f", in, "desc" -%&gt; SHtml.text(note.description.is, note.description(_)), "submit" -%&gt; SHtml.submit("Note It !", add)) ++ SHtml.hidden(add _) } def delete(note: Note): JsCmd = { note.delete_! NotesServer ! "refresh" S.notice("descMessage", "Note deleted.") } } object note extends RequestVar[Note]({ Note.create }) } </code></pre> <p>the html is </p> <pre><code> &lt;lift:surround with="default" at="content"&gt; &lt;div class="row"&gt; &lt;div class="span11"&gt; &lt;form class="lift:form.ajax"&gt; &lt;lift:Notes.noteForm&gt; &lt;f:desc id="desc" placeholder="what do you want to note?" class="xxlarge" /&gt; &lt;f:submit class="btn primary" /&gt; &lt;/lift:Notes.noteForm&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="span11"&gt; &lt;lift:msg id="descError" errorClass="alert-message error" /&gt; &lt;lift:msg id="descMessage" noticeClass="alert-message success" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="lift:comet?type=NotesComet" id="notes"&gt; &lt;div class="row show-grid"&gt; &lt;div class="note span10 lpad20"&gt; &lt;div style="display: inline" class="desclist"&gt;&lt;/div&gt; &lt;a class="close rpad10 tpad10" href="javascript://"&gt;&amp;times;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <p>code for comet </p> <pre><code>object NotesServer extends LiftActor with ListenerManager { def createUpdate = Note.allNotes override def lowPriority = _ match{ case "refresh" =&gt; updateListeners() } } class NotesComet extends CometActor with CometListener { private var notes: List[Note] = List() def registerWith = NotesServer override def lowPriority = { case n: List[Note] =&gt; notes = n; reRender() } def render = "#notes" #&gt; { (notes.reverse.map(note =&gt; ".desclist *" #&gt; note.description &amp; ".close [onclick]" #&gt; ajaxInvoke(() =&gt; Notes.delete(note)))) } } </code></pre> <p><strong>The message display works only for the first time perfectly with fade-in and fade-out, but fails subsequently.</strong> </p> <p>here is what i have in <code>Boot.scala</code> for fade in and fade out</p> <pre><code>LiftRules.noticesEffects.default.set((notice: Box[NoticeType.Value], id: String) =&gt; { Full(JqJsCmds.FadeOut(id, 2 seconds, 2 seconds)) }) </code></pre> <p>the following lift tag </p> <pre><code>&lt;lift:msg id="descError" errorClass="alert-message error" /&gt; </code></pre> <p>produces </p> <pre><code>&lt;span id="descError" &gt;&lt;/span&gt; </code></pre> <p>and after submit, the above html changes to the following. fade-in and fade-out works perfectly </p> <pre><code>&lt;span id="descError" style="display: none;"&gt; &lt;span id="descError"&gt; &lt;span class="alert-message error"&gt;Please enter a note&lt;/span&gt; &lt;/span&gt; &lt;/span&gt; </code></pre> <p>for the subsequent submit events the message is not shown because there are two span tags with same id <code>descError</code></p> <p>the problem is clear now, but not sure how to fix this.</p> <p><strong>update</strong> </p> <p>i tried the same code with liftweb 2.5-M3 and the difference i noticed is that the generated html after submit is as following. </p> <pre><code>&lt;span id="descError" style="display: none;"&gt; &lt;span class="alert-message error"&gt;Please enter a note&lt;/span&gt; &lt;/span&gt; </code></pre> <p>but still the message is not displayed for the subsequent submits.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload