ioquatix/jquery-syntax

$('#codefile-pre').syntax() doesn't work

Closed this issue · 3 comments

Only $.syntax() worked, however with selected jquery object, it doesn't work, even through it's exampled, such as:
$('div.java').syntax({
brush: 'java',
layout: 'fixed',
tabWidth: 8,
replace: true
});

I just checked and it is working on my end. Can you give me a full example?

I find out it should specify both 'layout' and 'blockLayout' at the sametime, otherwise it doesn't work.
My code fragment is generated dynamically via ajax call, once the code text retrieved from server side, I will invoke synatx api to create the synatx view, below is the my code for you reference:

 
               $.ajax({
                dataType : 'json',
                url : '/codefiles/xxx.java' +  
            }).done(function(data){
                $('#codefile-td').empty();
                $('#codefile-td').append('<pre></pre>');
                $('#codefile-td pre').text(data.text);
                $('#codefile-td pre').syntax({
                    theme: 'paper',
                    layout: 'fixed',
                    blockLayout: 'fixed',
                    replace: true
                }, function (options, html, container) {
                    // Draw cover block
                    return html;
                });
            });

Thanks. I will consider this issue you had when reviewing the documentation so it could be clear for new users.