Archive

Posts Tagged ‘Javascript’

如何在Lift里用javascript的confirm

May 13th, 2010 honnix No comments

使用Lift的SHtml.a()设计ajax调用的时候,老版本的Lift不支持给onclick加入用户自己定义的javascript方法,新版本的有了。

/**
   * Create an anchor tag around a body which will do an AJAX call and invoke the function
   *
   * @param jsFunc -- the user function that will be executed. This function will receive as last parameter
   *                  the function that will actually do the ajax call. Hence the user function can decide when
   * 				  to make the ajax request.
   * @param func - the function to invoke when the link is clicked
   * @param body - the NodeSeq to wrap in the anchor tag
   * @param attrs - the anchor node attributes
   */
  def a(jsFunc: Call, func: () =>; JsCmd, body: NodeSeq, attrs: (String, String)*): Elem = {
    attrs.foldLeft(fmapFunc(contextFuncBuilder(func))(name =>;
            <a onclick="{deferCall(Str(name" href="javascript://">{body}</a>))(_ % _)
  }

对于jsFunc可以这样理解:
用户定义了一个方法:

?View Code JAVASCRIPT
function delete(toDelete) {
  if (confirm("Delete?"))
    toDelete()
}

那么jsFunc可以这样定义:Call(“delete”),Lift会把它生成的ajax方法作为最后一个参数传递给delete方法。

感觉Safari比Firefox快多了

September 11th, 2009 honnix No comments

看网上的测试都说JS的处理Firefox要快,但是就我的感觉来说,Safari要快不少,用Google Reader的时候特别明显,FF有点卡,Safari完全没有问题。

FF的冷启动实在是太慢了,已经不能接受了。Safari快上很多倍。

所以Mac下准备投靠Safari了,唯一不爽的是没有Delicious的插件可以用。

Categories: Mac, Software Tags: , , ,