I have a Partial view which takes in parameters and displays a Markdown Editor based on the parameters passed.
@Html.Partial("_MarkdownEditor", new { id = "fieldsection" })
<div id="@ViewData.Eval("id")"> </div>
<script type="text/javascript">
var @ViewData.Eval("id") = new tui.Editor({
el: document.querySelector('#@ViewData.Eval("id")')})
</script>
In the source code of the tui.Editor i have a Ajax call to a controller something like this..
$.ajax({
url: 'Home/Index',
success: function (data) {
editor.importManager.eventManager.emit('command', 'AddImage'})
Here the problem is with this line..
editor.importManager.eventManager.emit('command', 'AddImage)
Here in the place of editor i need to reference the parameters passed to Partial view..it should be like this:
fieldcomments.importManager.eventManager.emit('command', 'AddImage)
It should be done dynamically i have tried something like..
{@ViewData.Eval("id")}.importManager.eventManager.emit('command', 'AddImage)
But this doesn't work like this? How can i reference the Parameters passed to Partial view in a separate javascript file??