+ Reply to Thread
Results 1 to 5 of 5

Thread: Add a button to copy url in comparison table

  1. #1
    Master
    Join Date
    Apr 2021
    Location
    USA
    Posts
    248

    Add a button to copy url in comparison table

    So I just playing around with the comparison table today. And the save table and be able to share the table url publicly is great. Think is many users don't know that. So I'm writing a button "copy url"
    Please see picture

    Attachment 4189

    Basically clicking on button will copy the table url. Here my code in bold

    Code:
    Only registered members can view the code.
    The url of table are printed above the button correctly.
    But for some reasons, the button always copy the url of the newest table, the table on top, even though I click on the second, third table button. How do I fix it so that it will copy the correspondant table url?

  2. #2
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,138
    Hello,

    Maybe your custom code in copyToClipboard function doesn't work properly

  3. #3
    Master
    Join Date
    Apr 2021
    Location
    USA
    Posts
    248
    Quote Originally Posted by Rudi View Post
    Hello,

    Maybe your custom code in copyToClipboard function doesn't work properly
    Hi Rudi,

    This is the code I added in the lib.js file in template

    Code:
    Only registered members can view the code.
    I have this setup to copy VIN number in listing detail page and it work fine because each listing only have 1 VIN. For the example I have below the list of comparison have more than 1 so I'm not sure. Click on copy button from the second, third and go on, always copy the 1st table url

  4. #4
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,138
    Instead of '#table_url' use '{$item.ID}' as a paramenter for your function

    and in the function body, get href by li data-table-id like:

    Code:
    Only registered members can view the code.

  5. #5
    Master
    Join Date
    Apr 2021
    Location
    USA
    Posts
    248
    Quote Originally Posted by Rudi View Post
    Instead of '#table_url' use '{$item.ID}' as a paramenter for your function

    and in the function body, get href by li data-table-id like:

    Code:
    Only registered members can view the code.
    That works perfectly. Thank you so much, Rudi.

+ Reply to Thread