0

Let me describe the layout of my page. There is a splitter on my page, the left page is the navigation panel and the right page is the content. So when the user, clicks a node on the panel, the content will be displayed on the right side. The problem is when the user supply a value on the displayed content, the remote validation is not firing. I tried this when the page is not a partial view and it was working.

Here is script when loading the partial view.

var onPanelItemSelect = function (e) {

    var windowPath;

    windowPath = $(e.item).attr('data-value');

    if (windowPath != '#') {

        $.ajax({
            type: 'GET',
            url: windowPath,
            success: function (data) {
                $('#right_pane').html(data);                                
            }
        });
    }

    return false;
}
tereško
  • 58,060
  • 25
  • 98
  • 150
Ice_Drop
  • 452
  • 1
  • 9
  • 19

5 Answers5

0

Essentially, I have a feeling that problem could also be that that property names are not bound correctly if you use the same model to bind the main page as well as the partial.

For example if you have a model class (called ModelClass) that has a property each for the two panels (called ModelClass.LeftPanel and ModelClass.RightPanel)

LeftPanel could have a property (TextProperty) that you use to bind to the right partial page. You would expect it to be named 'RightPanel.TextProperty' but it actually ends up with a name 'TextProperty'. This could also impact remote validations.

This Stackoverflow question describes what I think is the problem, as well as various solutions to it.

Hope this helps.

Community
  • 1
  • 1
Rahul
  • 478
  • 3
  • 8
  • got to look at the article but I think this is not the issue. My left panel and the right panel have unique property name. – Ice_Drop Jan 28 '13 at 08:25
0

Fixed the problem, I'm open if anyone has a better answer. On the header for each view I attach the validate and unobstrusive script.

Ice_Drop
  • 452
  • 1
  • 9
  • 19
0

Try this:

change

success: function (data) {
$('#right_pane').html(data);                                
}

to

success: function (data) {
$('#right_pane').html(data);
jQuery.validator.unobtrusive.parse("#right_pane");                                
}
Andreas
  • 240
  • 1
  • 2
  • 15
0

Please add reference to validate.min.js, and validate.unobtrusive.js in your partial page. Its working for me.

P.S: Am I too late :)

Roopali Rawat
  • 96
  • 1
  • 5
-1

My article has a descriptive code for remote validation , you can have a look at it .

Remote Validation Article

Shalin Jirawla
  • 489
  • 1
  • 5
  • 24