Created
April 16, 2013 01:41
-
-
Save rpgmaker/5392712 to your computer and use it in GitHub Desktop.
Razor JS with inline Html.Write
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span data-id='_1'></span> | |
<br/> | |
<span data-id='_2'></span> | |
<!--<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>--> | |
<script type='text/javascript'> | |
var Model = {}, | |
ViewResponse = function () { | |
return { | |
Buffer: jQuery('<div/>'), | |
Clear: function () { this.Buffer.empty(); }, | |
Write: function (data) { this.Buffer.append(data); }, | |
GetBuffer: function () { return this.Buffer.contents(); }, | |
SetBuffer: function (data) { this.Buffer = data; } | |
} | |
}; | |
(function(){ | |
var myVariable = 10; | |
var _1 = new ViewResponse(); | |
_1.Write("Test" + myVariable); | |
jQuery("span[data-id='_1']").replaceWith(_1.GetBuffer()); | |
var _2 = new ViewResponse(); | |
_2.Write("Test" + myVariable); | |
jQuery("span[data-id='_2']").replaceWith(_2.GetBuffer()); | |
})(); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
var myVariable = 10; | |
} | |
@{ Html.Write(""Test"" + myVariable); } | |
<br/> | |
@{Html.Write(""Test"" + myVariable); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment