views:

103

answers:

2

when i refresh a part of a webpage that has a jquery ui button, it seems like I have to call:

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

again or it shows up as a regular button. Thats fine but when i do this, it still shows up as a regular button for a split second before converting to the styling of the jquery theme. is there anyway to avoid this as it looks a bit messy.

NOTE: i noticed that this is for anything that i am theming using jquery ui like autocomplete, button, etc. so its not button specific issue.

+1  A: 

at what point do you widgetize the button? it seems to me like you are doing it a bit later then when you really want to do it.

also, can you try widgetizing the button before you add the DOM to your page.. it probably wont work, but worth a shot

so here is an example of what i said above:

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 

}

this might not work. but its worth a try.

mkoryak
@mkoryak - on the ajax callback, i am calling $(":button").button();
ooo
@mkoryak - how could that work as the call to .button() is based on a selector in the DOM.
ooo
i assumed the button that you are widgetizing is being pulled into the dom via ajax. if the button is not being updated via ajax, then why isnt it being widgetized before you make ajax call?
mkoryak
@mkoryak - i call it once on page load to get the theme. that works fine. After that, when i want to refresh that section i refresh that section on an ajax callback. It seems like i need to call $(":button").button(); again or it shows up like a regular button . . again, that ultimately works but it has this "hiccup" where it shows the regular button for a second.
ooo
why does the button show up as a regular button after you refresh another part of the page via ajax. this makes no sense, the button should stay widgetized
mkoryak
@mkoryak - the button is part of the page that is being refreshed so i am essentially creating the button again and then calling the .button() on it to have jquery theme it.
ooo
aha! ok i am going to edit my answer with an example of what you can try that i was talking about
mkoryak
@mkoryak - thanks for the updated answer. I didn't realize that you can make those calls outside of the page's dom
ooo
A: 

Did you get this figured out? I have the exact same issue.

Thanks

nparis
I just moved the jquery call to be done as soon as possible and now its hard to see when i use the jquery block ui plugin
ooo