0

I am using cordova 2.2.0 with Xcode 4.5.2. On one of my pages I have a select component and once a particular option is selected I want to display a table within a div. My html looks like this: <div class="hero-unit" id="#facprog"></div>

The javascript/jquery looks like this:

<pre><code>
$(function() { 
 $('#selFaculty').change(function() {
  var facultyName = $('#selFaculty').val();
  var progDetails = app.fillFacultyProgramme(facultyName);
  alert(progDetails);
  $('#facprog').append(progDetails);
 });
});
</code></pre>

Note that #selFaculty is the id of the select object. However, when the select option changes, everything in javascript executes except for the append. Nothing shows up in the div. Is there a different way to add html element to a div in jquery under cordova 2.2.0 in iOS? Thanks in advance, José

joque
  • 813
  • 2
  • 9
  • 14

1 Answers1

0

With jquery you can refresh a div.

This is a good example:

<script> 
    var auto_refresh = setInterval(
    function()
    {
         $('#loaddiv').fadeOut('slow').load('reload.php').fadeIn("slow");
     }, 20000);
 </script>

and now you need to put the div in the body section of your page

<div id="loaddiv"> 
</div>

from http://designgala.com/how-to-refresh-div-using-jquery/

and there is another example here:

refresh div with jquery

The first example is useful when you need to load a script and refresh and the second one is useful when you need to make a change, e.g. append html and then refresh as in your case.

Community
  • 1
  • 1
  • thanks for your quick response. Actually the problem was in my selector. I wasn't picking the right object. I had to navigate through the DOM till I find the object I was looking for. Now it works fine – joque Dec 14 '12 at 16:21