5

I am a developer Magento themes but I'm still learning how to work with the theme rwd.

I am getting a javascript error (below) when I see our store smaller screens resolution.

TypeError: this.toggleElements.toggleSingle is not a function
this.toggleElements.toggleSingle();

I don't understand the function below. I have copied the rdw package files to make the package from our store and have not changed any html tag in any of these files, just added my classes for CSS usage.

enquire.register('(max-width: ' + bp.medium + 'px)', {
    setup: function () {
        this.toggleElements = $j(
            // This selects the menu on the My Account and CMS pages
            '.col-left-first .block:not(.block-layered-nav) .block-title, ' +
                '.col-left-first .block-layered-nav .block-subtitle--filter, ' +
                '.sidebar:not(.col-left-first) .block .block-title'
        );
    },
    match: function () {
        this.toggleElements.toggleSingle();
    },
    unmatch: function () {
        this.toggleElements.toggleSingle({destruct: true});
    }
});

What can be causing this error?

10

I have had the same problem. Fixed it by checking the length of the element which needs to be toggled. The best thing you could do is rewrite this javascript file in your custom Magento theme that you use and add this code.

    match: function () {
        if(this.toggleElements.length > 0){
            this.toggleElements.toggleSingle();
        }
    },
    unmatch: function () {
        if(this.toggleElements.length > 0){
            this.toggleElements.toggleSingle({destruct: true});
        }
    }
| improve this answer | |
  • I had not thought of that. So simple that go unnoticed. Thank you very much. – Rone Clay Brasil Jun 9 '15 at 9:20
  • @jelle-siderius, thank you Jelle. Very helpful. – Andhi Irawan Jul 21 '16 at 9:39
8

the answer of jelle siderius doesn't work on my magento installation. I've fixed it, in changing this line

jQuery.fn.toggleSingle = function (options) {

in

$j.fn.toggleSingle = function (options) {
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.