Attach event not work on second page - Forum

Forum Navigation
You need to log in to create posts and topics.

Attach event not work on second page

I have a sample app with two pages, my script works perfect on first page but when I change the order of pages, it does not work. u can see it better in the below videos:

first video( work when order of page is first)

second video(not work when order of page become second)

 

This is my script, it has written under deviceready function:

 function createPDF(){
 var pdfer = document.getElementById("pdfcode").value; // pdfcode is id of textarea

 let options = {
        documentSize: 'A4',
        type: 'share'
      }

pdf.fromData(pdfer, options)
.then((stats)=> console.log('status', stats) )   // ok..., ok if it was able to handle the file to the OS.
.catch((err)=>console.err(err))
 }
document.getElementById("demo").addEventListener("click", createPDF); // demo is id of button

How can I solve this problem?

Hi @asmat, it's very difficult to know what's causing the problem. I normally use the web browser console to locate the problem but, as you are using a PhoneGap plugin not sure how you can debug it. Perhaps this could help:
http://docs.phonegap.com/references/developer-app/debugging/

Hi luishp, I think it is maybe cause of bootstrap pagination which hide the id of elements that are exist on second page.

The deviceReady function due to security reason maybe does not attach event to the hide elements.

Please take a look to the attachment, I think the problem that are in the attachment maybe similar with above one.

Uploaded files:
  • You need to login to have access to uploads.

Hi @asmat, although there is a limited posibility to modify them with NeoScript commands, objects in different pages than the current one are not accesible. So you can't assign a click event to a buttom from another button located in a diferent page.
I think this is the way AngularJS works (not BootStrap).
Sorry!