Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Guilherme_L_1
Beginner
216 Views

Problems with onclick event in IOS

Hi all,

I am developing a news app, and I chose to display only a preview of the news on the home screen that has a listview, when the user chooses one of the posts, I capture the news headlines and use to drive to a page also with a listview, but with the full content. On Android, it works correctly, but on iOS, only works in the emulator when I send to my iPad, by clicking on the news I'm not redirected to the page with the full content. Here my code so that they can evaluate:

$(document).on("click", "#listarPostagens > li", function(evt)

   {

       var titulo = $(this).attr("TITULO");
        
       $("#listarPostagem").empty();

        
           $.ajax({

             url: "http://xxx.xxx.xxx.xxx/postagem/"+titulo+"/1",

             type: 'GET',

             dataType: 'json',

             complete: function(xhr, textStatus) {
                
            },
             success: function(data, textStatus, xhr) {

 
               $.each(data,function(i,p){
                   var item = "<h5>"+p.titulo+"</h5>"+p.conteudo;
                   $("#listarPostagem").append(item);

               });
                   activate_page("#pgPostagem");
           },
           error: function (jqXHR, status) {
               alert("Erro ao acessar essa postagem, por favor tente mais tarde!");
           },
       });    

   });

I tried to debug, but I could not, every time I log in the app preview it closes the app on my iPad.

Best regards,

Guilherme

Tags (2)
0 Kudos
6 Replies
PaulF_IntelCorp
Employee
216 Views

Try upgrading the copy of jQuery in your app to jQuery 2 (see this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail <) and check the CSP rules and whitelist settings in your app.

Guilherme_L_1
Beginner
216 Views

Paul F. (Intel) wrote:

Try upgrading the copy of jQuery in your app to jQuery 2 (see this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail <) and check the CSP rules and whitelist settings in your app.

Thank you. Okay, but my code is based on the first that works perfectly even in IOS . What I think is happening is that should not is on the title , and so does not redirect to the next page.

Anyway , I irie check which version of JQuery and update .

Guilherme_L_1
Beginner
216 Views

Hi all,

I tried to follow his friend's suggestion, but did not work, I received the following error:

"multiple ui frameworks detected in document"

I believe that by bootstrap is the framework that I used for this project. What can I do to solve? Recalling that the first listview bearing the news works normal, the problem occurs when I try using the onclick event to capture the line of listview that the user clicked, the following code snippet:   

    $.each(data,function(i,p){ 

                 var item = '<li TITULO="'+p.titulo+'"<span style=color:#0B0B61><hr>'+p.postagem+'</span></li></hr>';
                 
                 $("#listarPostagens").append(item);
            });

and here

   $ (Document) .on ("click", "#listarPostagens> li", function (evt)

     {
         var title = $ (this) .attr ("TITLE");
          ...

 

I've tried, adding a "alert" for him to show me the captured content, but does not display anything. My computer does not recognize my iPad, so I can not debug and find out what is happening.

Any more suggestions?

Swati_S_Intel1
Employee
216 Views

@Guileherme, are you using Intent whitelist under the whitelist options? Try putting your URLs in the Navigation Whitelist also. And I'm assuming you are using Cordova CLI 5.4.1.  In Cordova iOS 4.1.0 (XDK CLI 5.4.1), the Intent whitelist does not work on click events, it's not clear if it's a bug or a security feature, but for now try putting your URL in Navigation Whitelist as well.

Guilherme_L_1
Beginner
216 Views

Hi SWATI,

I am using CLI 5.1.1, tried with 5.4.1 and also was not, I have attached my whitlist setting. I've tried removing all the plugins I'm using, but it did not work. Any more suggestions? Android goes quiet, the only problem with this IOS.

Fab_V_
New Contributor I
216 Views

i had a quite similar problem with click events.
I explain :

  • detected an IOS bug with click events not fired on elements except a.
  • environment cordova 5.4.1 / app framework 3
  • corrected the problem by adding a onclick attribute in the element.
<div id="mydiv">click my div</div>
<script>
$('#mydiv').on('click',function(){console.log('mydiv has been clicked');});
/* never fired*/
</script>

<div id="mydiv" onclick="">click my div</div>
<script>
$('#mydiv').on('click',function(){console.log('mydiv has been clicked');});
/* fired*/
</script>


 

Reply