sajjad aslam
sajjad aslam

Reputation: 47

Add Script On Click

I have two scripts running at the same time. 1 is jqueryUI and the other is touchpunch. I have a signbox made in canvas where users can digitally sign. The problem occurs on the mobile. THe signature are draggable as they are on a contract. but on mobile phones draggable does not work. So I used touchpunch, it makes the draggable work on the mobile but at the same time clicking on the signature box turns off. CLicking on the sign box open a modal box where you can sign. If I put touchpunch at the bottom, draggable works and box opening stops. If I put jqueryUI at the bottom, the touch works but the draggable doesnt. What I'm trying to find a way to only put the jqueryUI only. and when the user clicks the box and the sign box opens, then touchpunch gets added at the end. So after signing touchpunch start working and the sign becomes draggable. What I have done so far is this:


        alert("appending");

        var x = document.createElement('script');
        x.src = '{{ asset("js/touchpunch.js") }}';
        document.getElementsByTagName("body")[0].appendChild(x);

        alert("done appending");

    }

When I inspect, I do see that after opening the box, the script does get added but the box still doesnt become draggable. The overall question is, how can I add one script onclick and make it work. Or if you have any other suggestion, please let me know.

Upvotes: 1

Views: 186

Answers (0)

Related Questions