Inactive ajax calls loaded by wiring

35 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

mmigacz

nieprzeczytany,
8 kwi 2011, 11:42:548.04.2011
do Lift
Hi,
I already use simple wiring in my lift application and I think it is
great. Now, I’m trying to widely apply it, but I have a problem with
loading a page for the first time.
I have a page that displays a list of items taken from FuncCell. To
render it I use the following method:

WiringUI. toNode [T] (in: NodeSeq, cell: Cell [T] jsEffect: (String,
Boolean, JsCmd) =>JsCmd) (f (T, NodeSeq) => NodeSeq): NodeSeq

As I mentioned, problems arise when I enter the site directly for the
first time. I can notice that:
1. content blinks
2. if the NodeSeq returned by WiringUI.toNode contains any ajax call,
like links, forms etc, they are inactive. It seems that binding ajax
function with sever logic is outdated. This is the main problem I’m
struggling.

Probably the reason is that the lift returns to the browser raw
template with pagepostPageJavaScript, which loads the actual content.
When the content of page is reloaded by wiring again (because some
relations of FuncCell changed), than everything is ok and loaded ajax
calls are active
Is there any simple solution that allows to load rendered content at
the beginning?

Regards,
Maciek

David Pollak

nieprzeczytany,
8 kwi 2011, 13:52:568.04.2011
do lif...@googlegroups.com

I'm not following the failure.  Can you put together an example project so we can look at the unexpected behavior together?
 

Regards,
Maciek

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




--
Lift, the simply functional web framework http://liftweb.net

mmigacz

nieprzeczytany,
10 kwi 2011, 14:38:1810.04.2011
do Lift

Here is en example built on maven basic lift archetype

https://github.com/mmigacz/lift_wiring

Maciek




On 8 Kwi, 19:52, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> Beginning Scalahttp://www.apress.com/book/view/1430219890

mmigacz

nieprzeczytany,
13 kwi 2011, 11:32:4513.04.2011
do Lift
Hi,

I have added to the example https://github.com/mmigacz/lift_wiring an
index2.html page with two duplicated list of links. Both lists are
generated with the same method. The first one loaded with wiring is
inactive, while the second loaded directly is active.
Below a part of example snippet, tags2 generates both list


val tagFilter = ValueCell[Box[String]](Full(""))
val tagList = tagFilter.lift(_.map( p
=>tags.filter( _.startsWith(p) )).getOrElse(Nil))
val selectedTags = ValueCell[List[String]](Nil)

def tags2(xhtml: NodeSeq): NodeSeq = {
WiringUI.toNode(xhtml, tagList, JqWiringSupport.fade)((tags, ns)
=> renderTags(tags, ns)) ++
renderTags(tagList.currentValue._1, xhtml)
}


def renderTags( tags: List[String], ns: NodeSeq ): NodeSeq = {
("li" #> tags.map( row =>
".tag" #> SHtml.a(() => addTag(row), Text(row))
))(ns)
}


To run example https://github.com/mmigacz/lift_wiring just run: mvn
compile jetty:run-exploded

Maybe it is a bug of lift? I will be grateful for any help.
Maciek

mmigacz

nieprzeczytany,
14 kwi 2011, 10:11:5714.04.2011
do Lift

The problem is probably caused with a bug at
net.liftweb.http.WiringUI. addJsFunc[T](cell: Cell[T], f: (T, Boolean)
=> JsCmd) method. I have made some workaround by preparing my version
of addJsFunc (see wiring.lib.MyWiringUI), instead of:
if (first || (ct > lastTime && value != lastValue)) {
lastValue = value
lastTime = ct
f(value, first)
} else Noop
})

I've put:

if (first || (ct > lastTime && value != lastValue)) {
lastValue = value
lastTime = ct
Noop
} else{
f(value, first)
}

In addition the result of MyWiringUI.toNode method is wrrappded with
renderTags method to be sure, that the first generated content is
actual. Now it looks like this:

def tags2(xhtml: NodeSeq): NodeSeq = {
val ne = MyWiringUI.toNode(xhtml, tagList, JqWiringSupport.fade)
((tags, ns) => renderTags(tags, ns))
renderTags(tagList.currentValue._1, ne)
}

I think that above example will be a usefull suggestion where to
search a real soultion for someone more experineced than me (I'm still
fresh in lift). I can see that it is not just a my problem:
http://stackoverflow.com/questions/5572857/ajaxbutton-not-working-when-using-lift-wiring

I've updated the example https://github.com/mmigacz/lift_wiring with
described code.


btw. Today it's my birthday so it would be realy nice if I would get
an answer :)

Regards,
Maciek






On 13 Kwi, 17:32, mmigacz <maciejmig...@gmail.com> wrote:
> Hi,
>
> I have added to the examplehttps://github.com/mmigacz/lift_wiringan
> index2.html page with two duplicated list of links. Both lists are
> generated with the same method. The first one loaded with wiring is
> inactive, while the second loaded directly is active.
> Below a part of example snippet, tags2 generates both list
>
>   val tagFilter = ValueCell[Box[String]](Full(""))
>   val tagList = tagFilter.lift(_.map( p
> =>tags.filter( _.startsWith(p) )).getOrElse(Nil))
>   val selectedTags = ValueCell[List[String]](Nil)
>
>   def tags2(xhtml: NodeSeq): NodeSeq = {
>     WiringUI.toNode(xhtml, tagList, JqWiringSupport.fade)((tags, ns)
> => renderTags(tags, ns)) ++
>       renderTags(tagList.currentValue._1, xhtml)
>   }
>
>   def renderTags( tags: List[String], ns: NodeSeq ): NodeSeq = {
>     ("li" #> tags.map( row =>
>       ".tag" #> SHtml.a(() => addTag(row), Text(row))
>     ))(ns)
>   }
>
> To run examplehttps://github.com/mmigacz/lift_wiring just run: mvn
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0