I am getting the following Postback alert when I use the DotVVM <dot:Validator /> tags in my .dothtml pages. I cannot find any documentation on how to prevent this postback, control a timeout for it or control it's appearance. I am using the <dot:ValidationSummary /> tag at the bottom of my page and do not like the delay the Postback imposes. Any help would be appreciated.
Postback aborted because validation failed.
This happens when DotVVM is in the debug mode. If you didn't have any validator in the page and there was a validation error, you wouldn't notice that - that's why DotVVM displays this popup.
To remove it, you need to set config.Debug = false in DotvvmStartup.cs. You can use the following construct to detect the debug mode based on your build configuration:
private bool IsDebug
{
get
{
#if DEBUG
return true;
#else
return false;
#endif
}
}
Related
When using ckeditor links, images and table properties dialogs if the user clicks on cancel, CKEDITOR will check if anything has changed and if so prompts the user with js confirm popup.
How can I disable this prompt on cancel; no other dialogs in our webapp prompts on cancel and this is not consistent.
There doesn't' seem to be a way to get a list of all the handlers for an event to remove the one that's doing the prompt.
I don't want to specify a custom isChanged for each and every dialog item to hack a fake nothings changed.
Is there a standard way to override the base on('cancel',...) event handlers in CKEDITOR? I see that I can monkeypatch the dialogdefinition.OnLoad, OnOK, OnCancel handlers but this forced cancel prompt I'm referring to is not being done in the dialog's OnCancel.
I'm using the latest version 4.2
This is now a supported configuration option in version 4.3. Just specify config.dialog_noConfirmCancel = true when you create the dialog.
Check out http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-dialog_noConfirmCancel
You where very close. In fact it is in fact is the onCancel event.
There is a ticket for this problem that also includes a workaround:
CKEDITOR.on('dialogDefinition', function(dialogDefinitionEvent) {
if (dialogDefinitionEvent.data.name == 'link') {
var dialogDefinition = dialogDefinitionEvent.data.definition;
// Get rid of annoying confirmation dialog on cancel
dialogDefinition.dialog.on('cancel', function(cancelEvent) {
return false;
}, this, null, -1);
}
});
If you leave out the if (dialogDefinitioNEvent.data.name == 'link') statement it would disable the check for all dialogs.
The -1 handler parameter is the key here, as it inserts the handler before the dialog plugin's default handler, which will never be invoked because the return false cancels the bubbling of the cancel event to the other registered event listeners.
CKEditor Ticket #8331: Ability to ignore "Confirm Cancel"-warning on dialogs
I can confirm that the latest version of ckEditor works with the "noConfirmCancel" attribute.
A snippet of my working code is as follows:
<script type="text/javascript" src="#ckBasePath#/ckeditor.js" language="JavaScript"></script>
<script>
thisConfig = CKEDITOR.config;
thisConfig.autoParagraph = true;
thisConfig.fillEmptyBlocks= true;
thisConfig.dialog_noConfirmCancel = true;
objSample = CKEDITOR.replace( 'Sample' , thisConfig);
</script>
http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-dialog_noConfirmCancel
I have used Ajax.BeginForm / Html.BeginForm for a view which sends an object to the controller on clicking submit. There are some telerik controls which are disabled conditionally. On clicking submit, the object is unable to retrieve the already existing value in the control since it is disabled. Hence object is made with null values. Any help?
Im using jquery to disable these telerik controls on loading the page.
Change.setDropDownValues = function () {
if (condition) {
$("#A").data('tDropDownList').enabled = false; $("#A").data('tDropDownList').disable();
}
}
else if (condition) {
$('#Pop').attr('disabled', 'disabled'); //text box
$('#ShortDesc').attr('disabled', 'disabled'); //textarea
$('#LongDesc').attr('disabled', 'disabled'); //text area
$('#Cont').attr('disabled', 'disabled'); //text box
$('#iDate').attr('disabled', 'disabled'); //datepicker division
$('#C').data('tDropDownList').enabled = false; //drop down list
$('#C').data('tDropDownList').disable();
}
};
Can anyone say how to remodify so that I can fetch the disabled field values?
That's how disabled inputs work. They never send the value to the server. You could use readonly instead if you want to prevent the user from modifying the value and yet send the old value to the server when the form is submitted.
you can use something like this
$(":disabled", $('#yourform')).removeAttr("disabled");
before submit.
I use a tabView component with many tabs. In many of them, I have form which are submitted by primefaces commandButton component.
By default, PF commandButton using ajax mode but when I submit my form, my page seems to be fully loaded and my tabView component lost its index view (index 0 is rendered).
Is that normal behaviour please ?
I though that I would stay in the same index because it's ajax...
Looks like there is some naming container (p:tabView maybe) that you better assign an id to it , so instead of getting prefix like j_idt16 (which could vary from time to time) you will get myTab0 , myTab1 etc prefix...
for example <p:tabView id="myTab"
Another thing you could do to be on the safe side is checking if the element exists before trying to select it with jquery and access its value, like this
if($('#j_idt16\\:register_location_choice_2_input').length > 0){
//some code here
}
Ok, my problem is the JS validateRegisterForm function. When I remove it, it works but I need it...
I use it to check if validation form can be launched.
function validateRegisterForm(){
if($('#j_idt16\\:register_location_choice_2_input').attr('checked')){
if($('#j_idt16\\:register_galaxies_input').val() == 0){
var galaxie = MUST_CHOOSE_GALAXY;
alert(galaxie.charAt(0).toUpperCase() + galaxie.slice(1));
return false;
}
if($('#j_idt16\\:register_solar_systems_input').val() == 0){
var ss = MUST_CHOOSE_SOLAR_SYSTEM;
alert(ss.charAt(0).toUpperCase() + ss.slice(1));
return false;
}
if($('#j_idt16\\:register_positions_input').val() == 0){
var position = MUST_CHOOSE_POSITION;
alert(position.charAt(0).toUpperCase() + position.slice(1));
return false;
}
}
return true;
}
So how can I check fields values before sending and allowing or not validation form with ajax please ?
EDIT :
Ok, I solved my problem by launching validation inside my JS function with button type passed to button not submit and using remoteCommand component :
My JS function :
function validateRegisterForm(){
if(...)
validateForm();
}
And my remoteCommand :
<p:remoteCommand name="validateForm" actionListener="#{login.registerAccount()}"/>
I used jQuery validator and bound it to a click event like this :
var validator = $("#formId").data('validator');
When I click the first time I load the page I get the error "validator undefined", but when I refresh the same page it starts working.
any ideas?
Found the answer:
I use jQuery mobile and I had to turn the ajax off like this :
$.mobile.ajaxEnabled = false;
I have a problem with Dojo in Internet explorer 7/8 (this works fine in Firefox).
Basically I have a tab container with a number of tabs in it (these are dojox.layout.ContentPane's). On one of these tabs I want to have a "comments box" which would popup a dialog and ask the user to put something in. The comment is then saved by an call to the back end and I want the tab to reload to show the new comment.
The logic of my save button works something like this:
<button data-dojo-type="dijit.form.Button" type="button" data-dojo-props="iconClass:'dijitIcon dijitIconSave', showLabel: true" title="Add your comment">Add Comment
<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
require(["dojo/dom"], function(dom)
{
var tText = dijit.byId('comment_70').get('value');
if (tText == '')
{
alert('You have not entered any comment');
return;
}
var tJSONRPC = new JSONRpcClient('JSON-RPC');
try
{
tJSONRPC.be.addComment('70', tText);
var tTab = dijit.byId('Detail_70');
tTab.refresh();
}
catch (Ex)
{
alert(Ex);
}
});
</script></button>
Does not appear to be terrible taxing (the 70 at the end is the ID so that the user can have more than one of these open at the same time, hence the tabs).
As mentioned this works fine in Firefox but not in IE 8/7, it throws an error in some of the generated code within dojo (_32.focus(); to be precise), the error message I get in the debug console is "Unexpected call to method or property access"
Try this, with your line tTab.refresh();:
setTimeout(function() { tTab.refresh(); }, 0); // whenIdle
Its nearly impossible to tell where the thrown exception comes from - you should use the developement dojo-1.M.m-src/dojo/dojo.js code so optimized function- and variable-names are expanded (along with useful commenting once you step-through-debug).
Reason for the above is to eliminate, that exception occurs while handling button onclick-focus event (refresh will tear down DOM in the tab - along with your button)