Skip to content

Instantly share code, notes, and snippets.

@rpgmaker
Created April 16, 2013 04:34
Show Gist options
  • Save rpgmaker/5393368 to your computer and use it in GitHub Desktop.
Save rpgmaker/5393368 to your computer and use it in GitHub Desktop.
Razor JS with attribute
<span class='test' id='_1_a'><span data-id='_2'></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';
function _1_a(){ return attributeValue; }
jQuery('span[id="_1_a"]').attr('id', _1_a());
function _2(){ return value; }
jQuery("span[data-id='_2']").replaceWith(_2());
})();
</script>
@{
var attributeValue = 'Test';
var value = 'Value';
}
<span class='test' id='@attributeValue'>@value</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment