Last active
December 16, 2015 06:39
-
-
Save rpgmaker/5393381 to your computer and use it in GitHub Desktop.
Razor JS with multiple expression attribute
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 special = '_1_a' class='test' id='_2_a'><span data-id='_3'></span></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 attributeValue = 'Test'; | |
var value = 'Value'; | |
var anotherAttr = 'Something'; | |
function _1_a(){ return anotherAttr; } | |
jQuery('span[special="_1_a"]').attr('special', _1_a()); | |
function _2_a(){ return attributeValue; } | |
jQuery('span[id="_2_a"]').attr('id', _2_a()); | |
function _3(){ return value; } | |
jQuery("span[data-id='_3']").replaceWith(_3()); | |
})(); | |
</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 attributeValue = 'Test'; | |
var value = 'Value'; | |
var anotherAttr = 'Something'; | |
} | |
<span special = '@anotherAttr' class='test' id='@attributeValue'>@value</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment