Wrox Programmer Forums
|
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2010, 04:52 AM
Authorized User
 
Join Date: May 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default jquery - dynamic button...

Using jquery api,


Requirement:


When i click Start button i should show popup dialog window.
- popup dialog window contains StartNowButton & CloseButton
- If i click StartNowButton, i should show some default message and i would like to hide StartNowButton whereas CloseButton will display as it is...How to do ?
 
Old June 28th, 2010, 01:15 PM
Wrox Author
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

Quote:
Originally Posted by cloudsuser View Post
When i click Start button i should show popup dialog window.
- popup dialog window contains StartNowButton & CloseButton
- If i click StartNowButton, i should show some default message and i would like to hide StartNowButton whereas CloseButton will display as it is...How to do ?
If the start button has an id of start_button, you could do something like:

$('#start_button').dialog({
buttons: {"Start Now": function () {
alert("default message");
$(this).dialog("option", "buttons", {"Close": function () { $(this).dialog("close"); }});
},
"Close": function () { $(this).dialog("close"); }}
});
 
Old June 29th, 2010, 09:56 PM
Authorized User
 
Join Date: May 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default jquery - dialog button works only first time

I have four buttons, Start,Stop,Terminate,Reboot

Example:
When i click start button i will get dialog box which contains Start button and Cancel button.
As soon as when i clicked Start button
i will hide Start button and Cancel button and i will show only Close button with staic message as "In progress .. .."


Issues:
First time it works perfectly... some time its not working properly...
If i click start button it shows Terminate button...etc...mismatch...what may be the issues...

Note:
1) In other page i have the <div id="window-instance-status-popup" style="display:none"></div>
2) I have noticed that for first time of selecting the button works as expected...
and when we try to click second time with same button popup is not working, thrid time again its working.... So each button works like frist click success, second click fails, thrid click success...


Find the script below...

<script type="text/javascript">

var currentInstanceId;
$(function(){

$("#btn_asn_users").live('click', function(e){
AssignUsers(e);
});

$("#btn_assign").live('click', function(e){
insertRole(e);
});
$("#icon_str, #link_str").live('click', function(e){
startServerWindow(e, "StartInstance", currentInstanceId);
});

$("#icon_stp, #link_stp").live('click', function(e){
stopServerWindow(e, "StopInstance", currentInstanceId);
});

$("#icon_trmt, #link_trmt").live('click', function(e){
terminateServerWindow(e, "TerminateInstance", currentInstanceId);
});

$("#icon_rbt, #link_rbt").live('click', function(e){
rebootServerWindow(e, "RebootInstance", currentInstanceId);
});

});


function reloadProgressWindow() {

$("#window-instance-status-popup").html("In progress .. ..");

}

function startServerWindow(e, usersAction, currentInstanceId) {
alert('startServer selected...');
var url="<%=request.getContextPath()%>/cloudcomputing/showInstanceStatus.do?usersAction="+usersAction+"& instanceId="+currentInstanceId+"&init=firstRequest ";

$("#window-instance-status-popup").load(url, function(){
$(":button:contains('Close')").hide();
sameHeight('#asn_rightPane','#asn_leftPane');

}).dialog({
modal: true,
width: 425,
position: ['50%', '50%'],
draggable: true,
autoOpen: false,
title: usersAction,
closeText: 'hide',
buttons: {
"Cancel": function () {
$(this).dialog('close');
},
"Start": function () {
$(":button:contains('Start')").hide();
$(":button:contains('Cancel')").hide();
$(":button:contains('Close')").show();
reloadProgressWindow();
var successUrl="/myaction.do?startServerConfirmed=Yes&usersAction=" +usersAction;
$.post(successUrl, function(data) {
alert('startserver data: '+data);
reloadPageWindow(data);
});
},
"Close": function () {
showInstanceDetails(currentInstanceId);
$(this).dialog('close');
}
},
close: function (event, ui) {
$(this).dialog('destroy');
}
});
$("#window-instance-status-popup").dialog('open');
e.preventDefault();
}



function reloadPageWindow(data) {

$("#window-instance-status-popup").html(data);

}

function rebootServerWindow(e, usersAction, currentInstanceId) {
alert('rebootServer selected...');
var url="myaction.do?usersAction="+usersAction+"&insta nceId="+currentInstanceId;

$("#window-instance-status-popup").load(url, function(){
$(":button:contains('Close')").hide();
sameHeight('#asn_rightPane','#asn_leftPane');

}).dialog({
modal: true,
width: 425,
position: ['50%', '50%'],
draggable: true,
autoOpen: false,
title: usersAction,
closeText: 'hide',
buttons: {

"Cancel": function () {
$(this).dialog('close');
},
"Reboot": function () {
$(":button:contains('Reboot')").hide();
$(":button:contains('Cancel')").hide();
$(":button:contains('Close')").show();
reloadProgressWindow();
var url="<%=request.getContextPath()%>/cloudcomputing/showInstanceStatus.do?rebootServerConfirmed=Yes&us ersAction="+usersAction;
$.post(url, function(data) {
reloadPageWindow(data);
});
},
"Close": function () {
showInstanceDetails(currentInstanceId);
$(this).dialog('close');
}

},
close: function (event, ui) {
$(this).dialog('destroy');
}
});
$("#window-instance-status-popup").dialog('open');
e.preventDefault();
}


function stopServerWindow(e, usersAction, currentInstanceId) {
alert('stopServer selected...');
var url="myaction.do?usersAction="+usersAction+"&insta nceId="+currentInstanceId;

$("#window-instance-status-popup").load(url, function(){
$(":button:contains('Close')").hide();
sameHeight('#asn_rightPane','#asn_leftPane');

}).dialog({
modal: true,
width: 425,
position: ['50%', '50%'],
draggable: true,
autoOpen: false,
title: usersAction,
closeText: 'hide',
buttons: {

"Cancel": function () {
$(this).dialog('close');
},
"Stop": function () {
$(":button:contains('Stop')").hide();
$(":button:contains('Cancel')").hide();
$(":button:contains('Close')").show();
reloadProgressWindow();
var url="myaction.do?stopServerConfirmed=Yes&usersActi on="+usersAction;
$.post(url, function(data) {
reloadPageWindow(data);
});
},
"Close": function () {
showInstanceDetails(currentInstanceId);
$(this).dialog('close');
}

},
close: function (event, ui) {
$(this).dialog('destroy');
}
});
$("#window-instance-status-popup").dialog('open');
e.preventDefault();
}

function terminateServerWindow(e, usersAction, currentInstanceId) {
alert('terminateServer selected...');
var url="myaction.do?usersAction="+usersAction+"&insta nceId="+currentInstanceId;

$("#window-instance-status-popup").load(url, function(){
$(":button:contains('Close')").hide();
sameHeight('#asn_rightPane','#asn_leftPane');

}).dialog({
modal: true,
width: 425,
position: ['50%', '50%'],
draggable: true,
autoOpen: false,
title: usersAction,
closeText: 'hide',
buttons: {

"Cancel": function () {
$(this).dialog('close');
},
"Terminate": function () {
$(":button:contains('Terminate')").hide();
$(":button:contains('Cancel')").hide();
$(":button:contains('Close')").show();
reloadProgressWindow();
var url="myaction.do?terminateServerConfirmed=Yes&user sAction="+usersAction;
$.post(url, function(data) {
alert('terminateServer data: '+data);
reloadPageWindow(data);
});
},
"Close": function () {
showInstanceDetails(currentInstanceId);
$(this).dialog('close');
}

},
close: function (event, ui) {
$(this).dialog('destroy');
}
});
$("#window-instance-status-popup").dialog('open');
e.preventDefault();
}
 
Old June 29th, 2010, 10:22 PM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default

cloudsuser:
  • Please don't post the same message in more than 1 forum.
  • Please don't repost a moderated message. Wait for the moderator to approve it. If you post the same question 3 times and it's moderated 3 times, it's 3x as much work for us to find the real message and allow it.
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!





Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic button control SKhna ASP.NET 2.0 Basics 1 February 1st, 2008 10:36 AM
Dynamic radio Button gregd Classic ASP Basics 1 November 30th, 2006 09:42 AM
Dynamic image button Angel6784 ASP.NET 2.0 Basics 2 August 2nd, 2006 01:25 PM
Dynamic ASP button generation Lloyd_Christmas Classic ASP Basics 1 May 17th, 2005 06:50 PM
Dynamic Button Generation LouMattera BOOK: Professional C#, 2nd and 3rd Editions 2 March 4th, 2005 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.