vkaravir / bib-publication-list

Interactive publications lists with JavaScript + Bibtex
132 stars 63 forks source link

File Path leads to a 'Syntax error, unrecognized expression: output/bib/resources.bib' #14

Closed TuningGuide closed 8 years ago

TuningGuide commented 8 years ago

I would change it to something like:

return function(bibSrc, bibElemId, opts) {
...
        var $bibSrc = null;
        if(bibSrc.indexOf('/') === -1) {
            $bibSrc = $(bibSrc);
        }

        if ($bibSrc && $bibSrc.length) { // we found an element, use its HTML as bibtex
            new Bib2HTML($bibSrc.html(), $pubTable, options);
            $bibSrc.hide();
        } else { // otherwise we assume it is a URL
            var callbackHandler = function(data) {
                new Bib2HTML(data, $pubTable, options);
            };
            $.get(bibSrc, callbackHandler, "text");
        }
tdiethe commented 8 years ago

Minor changes to TuningGuide's code:

return function(bibSrc, bibElemId, opts) {
...
        var $bibSrc = null;
        if(bibsrc.indexOf('/') === -1) {
            $bibSrc = $(bibsrc);
        }

        if ($bibSrc && $bibSrc.length) { // we found an element, use its HTML as bibtex
            new Bib2HTML($bibSrc.html(), $pubTable, options);
            $bibSrc.hide();
        } else { // otherwise we assume it is a URL
            var callbackHandler = function(data) {
                new Bib2HTML(data, $pubTable, options);
            };
            $.get(bibsrc, callbackHandler, "text");
        }
vkaravir commented 8 years ago

Thanks guys! It was an issue with newer jQueries than the ancient version used by the example. Should be fixed in commit e8c1c2ac410d2fb4a5e6656779bf09fba9d51efc along with other jQuery issues.