【问题标题】:Sublime snippet for ajax not workingajax的崇高片段不起作用
【发布时间】:2016-04-07 01:15:12
【问题描述】:

我正在尝试创建一个片段,每次我键入ajax 时,都跟着tab 按钮插入代码,但是当我键入ajax 并按下tab 按钮时,它只会删除sn-p 的ajax 文本,我已经保存为 ajax.sublime-sn-p

我的sn-p

<snippet>
    <content><![CDATA[
    $('#${1:binder}').on("", function()
    {
        $.ajax({
            url: ${2:url},
            type: ${3:post},
            success: function(data)
            {
                if(!data.success)
                {
                    $('#error_message').html(data.error + alert_close).show();
                }else{
                    $('#success_message').html(data.success + alert_close).show();

                }
            }
        });
    });
]]></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>

我该如何解决这个问题?

【问题讨论】:

    标签: sublimetext3


    【解决方案1】:

    转义那些属于代码的美元符号,而不是 sn-p

    <snippet>
        <content><![CDATA[
        \$('#${1:binder}').on("", function()
        {
            \$.ajax({
                url: ${2:url},
                type: ${3:post},
                success: function(data)
                {
                    if(!data.success)
                    {
                        \$('#error_message').html(data.error + alert_close).show();
                    }else{
                        \$('#success_message').html(data.success + alert_close).show();    
    
                    }
                }
            });
        });
    ]]></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>
    

    您可能还想取消注释范围并将其设置为source.js

    【讨论】:

      猜你喜欢
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多