问题
I have just started using sublimeText2 since eclipse is really slow with large projects through a VPN. I am trying to bring over some of my snippets. Most are working ok but the follow one is a ajax call that I use but won't work as a snippet. I am guess that there are characters that need to be escaped or something but I am not sure which ones
<snippet>
<content><![CDATA[
$.ajax({
type: 'get',
url: '.cfc',
data: {method:''
, var: var
, var2:var
},
dataType: 'json',
async: false,
success: function(result){
var result = jQuery.trim(result);
console.log(result);
}
}
});
]]></content>
<tabTrigger>ajax</tabTrigger>
</snippet>
Can anyone see where I have gone wrong?
回答1:
Had to escape the $ with \$ and it works
<snippet>
<content><![CDATA[
\$.ajax({
type: 'get',
url: '.cfc',
data: {method:''
, var: var
, var2:var
},
dataType: 'json',
async: false,
success: function(result){
var result = jQuery.trim(result);
console.log(result);
}
}
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ajax</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
回答2:
Maybe the CDATA
tag enclosure causes this problem? Just a guess...
来源:https://stackoverflow.com/questions/13961566/new-to-sublime-cant-figure-out-snippets-with-javascript-in-them