Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15138

    Hello,

    I added a new jquery framework to display confirmation messages in the choices theme and I get an error

    Here is the script that I added (to reproduce the problem)

    (function($){

    $.confirm = function(){

    alert(‘confirm’);

    }

    $.confirm.hide = function(){

    alert(‘confirm hide’);

    }

    })(jQuery);

    Each time I call $.confirm() I get an error that the confirm method does not exist.

    If I remove the references to

    <script type=’text/javascript’ src=’/Content/themes/choices/js/avia.js’></script>

    <script type=”text/javascript” src=”Content/themes/choices/js/avia_styleswitch.js”></script>

    My confirm method works just fine.

    So my guess is that the avia framework does something to jquery, so that other components cannot register extension methods

    Do you know what it might be ?

    If the question is not clear, I will try to elaborate, let me know.

    Thank you,

    Andrei Gavrila

    #86354

    Hi Andrei Gavrila,

    I’m not sure how to fix it. Let me tag Peter to check this issue. :)

    Regards,

    Ismael

    #86355

    1) Try following code instead:

    (function($){
    $.fn.alertconfirm = function(options){

    var defaults = {
    hide: false
    };

    var options = $.extend(defaults, options);

    if(options.hide == true)
    {
    alert('confirm hide');
    }
    else
    {
    alert('confirm');
    }
    }
    })(jQuery);

    You should be able to call the alert box with following code now:

    jQuery('a').on( 'click', alertconfirm({ hide: false }) );

    and:

    jQuery('a').on( 'click', alertconfirm({ hide: true }) );

    Update: I think this is not a clever solution anyway because there’s already a default confirm() function in js. Thus you can create the same effect with eg following code:

    function confirmcheck()
    {
    var answer = confirm("Do you really want to hide the element?");
    if (answer){
    return true;
    }
    else
    {
    return false;
    }

    }

    and call this function like:

    jQuery('a').on( 'click', confirmcheck() );

    #86356

    Thanks for the input.

    We also have some problems when using $ instead of jQuery.

    Could you please tell me if you know why ?

    This call works: jQuery('video,audio').mediaelementplayer(/* Options */);

    This one returns an error: $('video,audio').mediaelementplayer(/* Options */);

    The error message is Uncaught TypeError: Property ‘$’ of object [object Window] is not a function.

    If we remove the references to

    <script type='text/javascript' src='/Content/themes/choices/js/avia.js'></script>
    <script type="text/javascript" src="Content/themes/choices/js/avia_styleswitch.js"></script>

    $ works properly.

    Could you please tell me why this happens. We are pretty concerned now on using the avia framework, since other frameworks that we use might use $ and might get broken.

    Thank you

    #86357

    Hey!

    Yes, the reason is that Kriesi uses the noconflict mode: http://api.jquery.com/jQuery.noConflict/

    Best regards,

    Peter

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Choices jquery error’ is closed to new replies.