Okay
  Public Ticket #1946737
Save some code lines
Closed

Comments

  • Sungho Lee started the conversation

    Hello,

    Ever since I purchased this product, I am using it with great satisfaction. I mostly using the popups and I trigger them by clicking event. I put about 5 to 8 popups hidden each page and placed buttons to call them over.

    There are 2 parts to activate the slider popup. One is CSS markup and the other is SCRIPT part. CSS markup is all different. No matter how huge the lines are, it is not a problem. However the script part is all same except only 2 places as belows. They are all pairs.

    1. $('#slider_A').layerSlider({ . . .}); // places at the beginning.

    2. popupShowOnClick: '#open_A', // places in the middle.

    The script code group is getting bigger yet has all the same lines except 'id' name. It looks quite awful. I heard that some 'rel' attribute can make this short and save spaces. I tried to figure it out, but couldn't make it. Could you give me some advice on this? 

    Thanks,

  • [deleted] replied

    Hello Lee,

    Thank you for getting in touch with us. My name is Attila and I'm happy to assist you today.

    I would like to confirm that we have received your message. Due to the nature of your query, I will have to contact and consult with the development team first. I will get back to you as soon as I can.

    We appreciate your patience while we're working towards your ticket.

  • [deleted] replied

    Thank you for your patience. You could do this the following way. 

    Set a class (for example class="openpopup") on every button that opens a popup. The slider IDs you have set (slider_a, slider_b, etc) are correct, so keep those. After this, you can set a data attribute (data-slider-id) on the above mentioned popup opening buttons, and set its value to match the popup slider's ID that you want to open. So for example data-slider-id="slider_a"

    The code will look something like this:

    jQuery( '.openpopup' ).on( 'click', function(){
        jQuery(  '#' + jQuery( this ).data( 'slider-id' ) ).layerSlider( 'openPopup' );
    });

    But in this case you do not have to set the popupShowOnClick parameter in the init code.