I have the following question for you guys:
I have a js file for an editable datatable. When a user clicks to edit a row, the cell contents are changed out with a control to edit the contents of that cell through injecting HTML via js.
This all works well for a simple text input, but gets a bit more tricky with things like drop-downs where the amount of markup to be injected increases exponentially.
What I would like to do is use the MVC HTML helpers to generate the code for dropdowns (based on values passed in through the model passed to the view).
What would be the easiest way to do this, as the HTML helpers do not work in external JS files.
The code in the JS file is as follows:
When coding the dropdown manually, things come out looking more horrible:
This gets messy and I have yet to figure out how to pass in the list of options for each of the drop-downs (there would be 2 dropdowns and a textbox for each line. The options for the 2 dropdowns are different.
How do I get around this?
Cheers
I have a js file for an editable datatable. When a user clicks to edit a row, the cell contents are changed out with a control to edit the contents of that cell through injecting HTML via js.
This all works well for a simple text input, but gets a bit more tricky with things like drop-downs where the amount of markup to be injected increases exponentially.
What I would like to do is use the MVC HTML helpers to generate the code for dropdowns (based on values passed in through the model passed to the view).
What would be the easiest way to do this, as the HTML helpers do not work in external JS files.
The code in the JS file is as follows:
Code:
jqTds[3].innerHTML = '<input type="text" class="form-control input-small" value="' + aData[3] + '">';
When coding the dropdown manually, things come out looking more horrible:
Code:
jqTds[2].innerHTML = '<select class="form-control"><option value="Nikon">Nikon</option><option value="Canon">Canon</option></select>';
This gets messy and I have yet to figure out how to pass in the list of options for each of the drop-downs (there would be 2 dropdowns and a textbox for each line. The options for the 2 dropdowns are different.
How do I get around this?
Cheers