为什么在使用ajax更新页面后,jquery按钮需要一秒钟才能刷新

时间:2010-05-12 13:10:10

标签: jquery jquery-ui-button

当我刷新一个带有jquery ui按钮的网页的一部分时,似乎我必须打电话:

$(":button").button();
再次

或它显示为常规按钮。这很好,但是当我这样做时,它仍然会在转换为jquery主题的样式之前显示为常规按钮一瞬间。无论如何要避免这种情况,因为它看起来有点乱。

注意:我注意到这是针对我使用jquery ui的所有内容,例如自动完成,按钮等,所以它不是特定于按钮的问题。

1 个答案:

答案 0 :(得分:1)

你在什么时候按下按钮?在我看来,就像你之前做的那样,当你真的想要这样做时。

另外,在将DOM添加到页面之前,您是否可以尝试对按钮进行小工具...它可能无法正常工作,但值得一试

所以这是我上面所说的一个例子:

function(data){ //so this is the success function which is called when your ajax comes back and you need to write that data to some part of the page.

  var $data = $(data); //create the dom for the new stuff but do not append into the page's dom yet!

  $data.find(":button").button()//widgetize the buttons now

  $("#page_of_the_page_to_be_updated").append($data); //update the page 

}

这可能不起作用。但值得一试。

相关问题