ajax - How to render/not render Close link of Jquery dialog box? -
i have/can have 1 jquery dialog box. dialog box has advertisement content user. on reading it, user can avail offer or ignore time being.
user can avail offer clicking on submit button inside dialog box. or can ignore clicking on "remind me later" link close dialog box. contents inside dialog box updated through ajax. when submit button clicked, thank message shown inside same dialog box.
when user avails offer, "remind me later" link still there. if user clicks on that, logically, dialog box should shown again. but, user has availed offer!
how can render or not render close link of jquery dialog box programatically?
code dialog box below,
$h(document).ready(function() { $h("#showform").dialog({ open: function(event, ui) { jquery('.ui-dialog-titlebar-close').html('<span>remind me later</span>'); jquery('.ui-dialog-content').removeclass("ui-dialog-content").addclass("advertise-upgrade-content"); }, duration: 800, height: 727, minwidth: 811, width: 811, position: ['middle', 154], zindex: 99999999, modal: true, show: { effect: 'puff', duration: 400 }, hide: { effect: 'puff', duration: 400 } }); }); <div id="showform" height: 670px;"> <div class="submitclass"> <a4j:commandlink immediate="true" action="#{mybean.clicktoavail}" rerender="rendersuccess" value="submit"> </a4j:commandlink> </div> <h:panelgroup id="rendersuccess"> <h:outputtext value="thank availing offer"> </h:panelgroup> </div>
am using jquery.min.js
, jquery-1.6.2.js
, jquery-ui.min.js
.
in open
function, make logical check whether thank you
message container visible (assuming it's visible if user has availed offer) , if it's visible, hide close
('remind me later' in case) or else, show it.
also, you're using generic code manipulate attributes of dialogue in open
. should make use of ui
variableto make code specific current dialog
refer this thread both close
manipulation , example usage of ui
variable
edit: making 4 changes
1) give id span
nb: still needs specific dialog. please refer thread mentioned above.
jquery('.ui-dialog-titlebar-close').html('<span id=\'reminder\'>remind me
later');
2) define boolean variable availed
in bean , set in clicktoavail
method
public void clicktoavail(){ // business logic here this.availed = true; }
3) use data
, oncomplete
<a4j:commandlink immediate="true" action="#{mybean.clicktoavail}" data="#{mybean.availed}" rerender="rendersuccess" value="submit" oncomplete="removereminder(event.data);"> </a4j:commandlink>
4) define removereminder
javascript function in <head>
of page
function removereminder(availed){ if(availed == 'true' || availed == true) $('#reminder').hide(); // or remove() decide per requirement }
Comments
Post a Comment