ASP.NET MVC, Loading forms via PartialViews - asp.net-mvc-2

I am developing an application using ASP.Net MVC and jQuery. Depending on users action, I load partial views into the page using jQuery's $.ajax method.
The problem, I am experiencing, is related to a particular partial view that contains a form, in which the client side validation is enabled. It does seem like the JavaScript code generated in this partial view is not being executed, hence the client validation is not working.
Does anybody have a solution for this issue?
Thanks!
Zen

You might need to put all scripts contained in this partial into a separate function. Then in the success callback of you AJAX request simply call this function: it should attach validation to the newly modified DOM.

Related

Why insert style again on client-side when using ssr? (from MUI docs)

I was going through Mui's Server-side Rendering DOCS.
And It says to prevent FOUC, we should inject style to rendered HTML on server side.
This was very clear.
But after that, it says "On the client-side, the CSS will be injected a second time before removing the server-side injected CSS."
this is the part I don't get.
why should we inject CSS again on client-side if it's already injected server-side?
Is there any difference between client-side cache and server-side cache?
And what is benefit of doing this?
If I had to guess, it would be that if some new Material UI element appears during runtime, the client needs to be able to handle that. SSR after all is for the initial loading of the page. So basically it is client rerendered to allow being dynamic.
This however creates issues for me personally as well since the new tag overwrites my Tailwind . Am trying to figure out how to render the client version above/before the Tailwind one, hence is why your question popped up on Google.
Edit: If I remember correctly, I solved using emotion; https://emotion.sh/docs/ssr

Is there / What is a suggested way to create autocompleted form fields in ZF2?

Does the ZF2 Form (zendframework/zend-form) provide a mechanism to create text fields with autocompleted value list? Or is it just done by using the common Zend\Form\Element\Text, a Controller, that provides the data, and some JavaScript (not by ZF generated, but implemented in any proper way)?
You can use jQuery Autocomplete field with Any Framework or CMS, You can grab it here. https://jqueryui.com/autocomplete/
Its quite simple and easy to use.
You can fill source array on document.ready() or on field.change() or on field.keypress() events as per your requirements using Ajax.
Or you can read similar Resolved issue here
JQuery UI Autocomplete with Zend Framework
Zend Form doesn't have such mechanism, so proper way is use AJAX request with JSON response. See Rob Allen's tutorial for this:
Returning JSON from a ZF2 controller action

Why no Zend_Layout helper or codebehind? And best way to

I was just wondering why no code-behind or helpers were made to work with layouts? I have stuff I want to display in my layouts without having to set it up in a placeholder for every single controller.
I was also wanted to know what is the best way to persist a display-once "success-message" across many pages. For example, a user fills out a form and when it is submitted correctly they are redirected to another page. I want the user to see a success message on that other page. Is there some sort of provision in Zend Framework that makes this easier?
Well for the messages you can use the Flash Messenger helper
As far as setting up the place holders you could use a base controller and set these up in the init method overriding on descendents when necessary.

Calling Javascript Validation Methods on ASP.NET MVC 2 View's form submitting?

How to invoke Form Validation Javascript methods before submitting ASP.NET MVC view?
this is guide to client side validation.
http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx
and when you complete the file check what is generated for you. this will be nice start for you.
hope this helps.

Should I generate html form?

I'm building a php application that will have many modules/plugins. The issue is that creating smarty template for form's of each plugin and writing validation code for each looks redundant and at the same time using PHP to generate form will restrict the flexibility in controlling each form's layout structure the way I would have wanted.
Using PHP classes and inheritance you can write the validation and layout code once and overriding them whenever you need specific behaviour.