Giter VIP home page Giter VIP logo

Comments (13)

BorisMoore avatar BorisMoore commented on May 17, 2024

Closing this issue for now. HTML5 structural elements in current browsers which have no built-in support for them is not a target scenario for jquery-tmpl at this point. (We are currently in Beta and for our first release have many other target scenarios we need to address). That said, a version of innerShiv or similar that works with templates may be possible. But it cannot be supported by specific code in the official plugin...

from jquery-tmpl.

andy-clusta avatar andy-clusta commented on May 17, 2024

I have got innerShiv to work with jquery-templ by adding innerShiv to the private function named build. Refactoring the jQuery( middle ) call on line 296 to allow this to be easily overridden would be very helpful.

Line 296: frag = jQuery( innerShiv ( middle ) ).get();

from jquery-tmpl.

andy-clusta avatar andy-clusta commented on May 17, 2024

eg. a PreInject or OnInjecting method which could be overloaded, to add innerShiv as required.

from jquery-tmpl.

BorisMoore avatar BorisMoore commented on May 17, 2024

Thanks. I'll consider that if we do significant iterations on that part of the code.

from jquery-tmpl.

KrofDrakula avatar KrofDrakula commented on May 17, 2024

+1, in HTML5 apps, this is a blocker issue, since no widgets can use HTML5 elements in their templates; the fix by andy-clusta did help, but would love to see this integrated upstream.

from jquery-tmpl.

BorisMoore avatar BorisMoore commented on May 17, 2024

I've reopened this issue, for investigation. Not sure how soon we will be able to address it though...

from jquery-tmpl.

KrofDrakula avatar KrofDrakula commented on May 17, 2024

I've done some more testing on a live example; seems the simple wrapping with innershiv doesn't work correctly, since instead of DOM elements, it returns a document fragment that botches up rendering. I didn't have time to investigate further, but something to help with the resolution.

from jquery-tmpl.

andy-clusta avatar andy-clusta commented on May 17, 2024

My latest approach has been to patch jQuery itself, rather than jQuery plugins individually. The following code works fairly reasonably for my use cases. Crucially, it ensures scripts returned in a partial are also evaluated, but after dom insertion.

var init = $.fn.init;
var html = $.fn.html;

// used by Jquery Templates
// tests to see if html passed to constructor
$.fn.init = function (selector, context) {
    if ($.browser.msie && typeof selector == 'string' && selector.indexOf('>') != -1 && selector.indexOf('<') != -1) {
        return new init(innerShiv(selector, false));
    }

    return new init(selector, context);
};

// used by Jquery Unobtrusive Ajax in ASP.NET MVC
// only matches <script></script> tags, without @src and @type
$.fn.html = function (value) {
    if ($.browser.msie && value != null) {
        var scriptsRegex = new RegExp('<script>([\\w\\W]*)</script>', 'gim');
        var scripts = value.match(scriptsRegex);
        var el = html.apply(this, [innerShiv(value, false)]);

        for (var i in scripts) {
            var js = scriptsRegex.exec(scripts[i]);
            if(js != null)
                $.globalEval(js[0]);
        }

        return el;
    }

    return html.apply(this, arguments);
};

from jquery-tmpl.

KrofDrakula avatar KrofDrakula commented on May 17, 2024

@andy-clusta: I've modified your script a bit (added function name to avoid having the var declarations) and added innershiv to the file: https://gist.github.com/822134

from jquery-tmpl.

tehnorm avatar tehnorm commented on May 17, 2024

if it matters +1 for this fix being worked in. We are using HTML5 and are experiencing IE's "challenges" with HTML5. Also - thanks again for jquery-tmpl - great stuff!!

from jquery-tmpl.

Akkuma avatar Akkuma commented on May 17, 2024

@KrofDrakula & @andy-clusta
I've now made a jQuery 1.5+ compatible version, which integrates the innerShiv directly into the function to remove it from the global namespace.

https://gist.github.com/887560

from jquery-tmpl.

rosshadden avatar rosshadden commented on May 17, 2024

Is there any way the tmpl plugin can be fixed to correct this, so no additional code is required? This is hands-down an issue with jquery-tmpl, so modifying jQuery and/or the shiv are not the best approaches.

from jquery-tmpl.

rdworth avatar rdworth commented on May 17, 2024

Thanks for taking the time to submit this issue. Just wanted to let you know this plugin is no longer being actively developed or maintained by the jQuery team. See README for more info.

from jquery-tmpl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.