jquery - Calling javascript on document.Load() passing C# parameters -
I have a JavaScript function that I need to run. It takes some parameters in the actual parameters in my visual model I need to call this javascript multiple times because the elements in the collection are the elements of the collection, as well as each time the related parameters are there.
When this document loads the document, I thought I should call this function in the call. The problem is that I do not know how to loop through my C # archive and generate JavaScript at the same time. Do you know how I can get it?
Thanks
You can serialize your view to JSON and your model Renderer inside the script block in the view:
& lt; Script type = "text / javascript" & gt; $ (Function () {var collection = @ Html.Raw (Json.Encode (model)); $ .eec (collection, function (i, value) {yourFunction (value);});}); & Lt; / Script & gt;
Comments
Post a Comment