How to change jquery's dialog button label at run time
Tech-Today

How to change jquery's dialog button label at run time


Recently I've used a 3rd party jquery library that pops up a jquery dialog with form content. However if has a default button Save and Cancel, which most of the time is ok, but sometimes you have need to localized or change the label depending on your need. For example in my case I use the popup form to reply to an email, so I need the button with a label "Send". Here's how I did it:


Here we use localizedButtons variable to hold the 2 button function, which has dialogBtnOk button. The label of this button can be overridden on any form you want by simply initializing it inside a script tag as: var dialogBtnOk = "Send";

if (typeof dialogBtnOk === 'undefined') {
dialogBtnOk = "Save";
}

localizedButtons[dialogBtnOk] = function () {
// Manually submit the form
var form = $('form', this);
$(form).submit();
}

localizedButtons['Cancel'] = function () {
$(this).dialog('close');
}

// Load the form into the dialog div
$(dialogDiv).load(this.href, function () {
$(this).dialog({
modal: true,
resizable: false,
title: dialogTitle,
buttons: localizedButtons,
open: function (event, ui) { },
close: function (event, ui) {
$(this).dialog("destroy");
$(this).remove();
}
});

// Enable client side validation
$.validator.unobtrusive.parse(this);

// Setup the ajax submit logic
wireUpForm(this, updateTargetId, updateUrl);
});




- Mvc3 Ajax Validation Doesn't Work On A Jquery Served Form
To make automatic validation using data annotation on a model on mvc3 c# we need: 1.) A model with data annotation (ex. required attribute). 2.) Form with jquery declaration (jquery1.7, validate, validate unobtrusive, and unobtrusive-ajax. All are available...

- How To Upload A File In An Mvc3 C# Ajax Form
It's easy to upload file in a synchronous form, where you just post the file and read a HttpPostedFile variable in the server side: In plain html form, take note of the form enctype property: //the view (index.cshtml) @using (Html.BeginForm("Upload",...

- Adding Loading Screen To C# Mvc Ajax Dialog Form Using Jquery
With my experience from telerik, I want my entity's add and edit form to be a popup so I don't have to change screen. I'm using C# MVC3, so I tried to look for jquery add on that would do the job. Fortunately I've come up with this article:...

- Jquery Copy Form Values Into Another Form
Recently I have a requirement to have two form on a single page. Why? It's because I have a search form that query records from the database with the aid of ajax. Then another form to generate a report based from the filters specified in the first...

- Docmd.close Acform, Frmname Not Working
Playing with the old VB form in MS Access, I have this weird error. I have 2 forms: form1 and form2, when I am in form2 there is a close button there, and when I press that button which has a button click action: DoCmd.Close acForm, form2.Name The...



Tech-Today








.