Adding new button to Popup Form

Sep 5, 2011 at 6:09 AM

Hi,

I would like to add a new button (say Help) apart from OK & Cancel button to Popup Form. Could I know how to do this?

Regards,
Chandru. BK

 

 

Coordinator
Sep 5, 2011 at 2:23 PM

Hi,

The popup form doesn't has this option, you can't add buttons, you can do it with the Popup, but that one doesn't has a form

you could try a js workaround like this (after the MakePopupForm helper):

var btns = $("#popupdivid" ).dialog( "option", "buttons" );
btns.push({text:'help', click: function(){alert('hi');}});
$("#popupdivid" ).dialog( "option", "buttons", btns );


Sep 5, 2011 at 2:50 PM

Hi ,

Thanks for the quick response.

I did tried below option in my view page and didn’t worked. My controller name is “User”

<%=Html.MakePopupForm("Edit", new[] { "id" }, successFunction: "Reload", title: “User”, width: 100, height: 200, fullScreen: true)%>

<script type="text/javascript" language="javascript">

var btns = $("#pfedituser").dialog("option", "buttons"); btns.push({ text: 'help', click: function () { alert('hi'); } }); $("#pfedituser").dialog("option", "buttons", btns);

</script>

I need to have the help button in the places as shown in the below image.

From: o [email removed]
Sent: Monday, September 05, 2011 7:54 PM
To: Chandru B.K.
Subject: Re: Adding new button to Popup Form [awesome:271474]

From: o

Hi,

The popup form doesn't has this option, you can't add buttons, you can do it with the Popup, but that one doesn't has a form

you could try a js workaround like this (after the MakePopupForm helper):

var btns = $("#popupdivid" ).dialog( "option", "buttons" );
btns.push({text:'help', click: function(){alert('hi');}});
$("#popupdivid" ).dialog( "option", "buttons", btns );
 
 
 
DISCLAIMER: This email message and all attachments are confidential and may contain information that is privileged, confidential or exempt from disclosure under applicable law.  If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this email is strictly prohibited. If you have received this email in error, please notify us immediately by return email or to mailadmin@spanservices.com and destroy the original message.  Opinions, conclusions and other information in this message that do not relate to the official business of SPAN, shall be understood to be neither given nor endorsed by SPAN.
Coordinator
Sep 5, 2011 at 5:09 PM

try to put the js code  inside

$(function(){

//the stuff

});

Sep 8, 2011 at 9:10 AM
Edited Sep 8, 2011 at 9:11 AM

 

 Hi

 

 

I have tried your suggestion and I’m getting below error. Can you please help me on the same?

Error I’m getting is “btns.push is not a function” I’m using IE 8 and Firefox 6.1 for my testing

 

<

 

 

 

 

asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat

 

 

<%

 

=Html.PopupFormActionLink("Create", text: "Create Address",controller:"Home"

 

 

=Html.MakePopupForm("Create", new[] { "id" }, title: "Create", width: 400, height: 500, fullScreen: false

 

 

<script type="text/javascript" language

 

$(

 

function

 

 

var btns = $("#pfcreatehome").dialog("option", "buttons"

 

 

'help', click: function () { alert('hi'

 

 

"#pfcreatehome").dialog("option", "buttons"

 

 

</script

 

 

asp:Content

 

 

 

>

 

 

>

</

 

, btns);

 

});

 

); } });

$(

 

);

btns.push({ text:

 

() {

 

 

 

="javascript">

)%>

 

 

)%>

<%

 

 

="server">

Coordinator
Sep 8, 2011 at 12:49 PM

well look at the type of the btns (do alert( typeof btns))

it could be an object so you could do btns.help = function(){alert('you clicked ');} intstead;

look here http://jqueryui.com/demos/dialog/