page include inline javascript not running & has anyone done a progress bar?

Pat VachonPat Vachon Member ✭✭
edited June 25 in Questions



Comments

  • Moshe KarmelMoshe Karmel Member
    edited June 25
    I think that the issue is that a page include is basically a webpage inside of a webpage. The inner webpage and outer webpage may be having some conflicts with Ids and stuff. I would put a console.log() inside your snippet and see if it's even getting called. As far as progress bars... Check this out: http://jqueryui.com/progressbar/
  • Pat VachonPat Vachon Member ✭✭
    edited January 2016
    Good call. console.log. Here are the results.
    image
    This line fails to get the input checkboxes. Works fine in the page by itself, but not in the page include.
    var checkboxes = $("#reportoptions :input[type=checkbox]");  
    Here's the code in total.
    (function(skuid){    console.log('ReconReports have run');  var $ = skuid.$;  $(function myfunction(){            console.log('ReconReports myFunction runs');   var checkboxes = $("#reportoptions :input[type=checkbox]");                      console.log('ReconReports checkboxes count ' + checkboxes.length);                  for(var i=0, n=checkboxes.length;i<n;i++) {             checkboxes[i].checked = true;         }  }); })(skuid);
  • Pat VachonPat Vachon Member ✭✭
    edited January 2016
    Inspecting elements as page include.
    image

    Inspecting elements as page.
    image

    Both should work the same based on this.
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    bump
  • J.J. Skuad ✭✭
    edited June 25
    Pat,

    I think your inline JS is getting run before those checkboxes are added to the DOM. Try wrapping myFunction in a jQuery.one on the pageload event:
    (function(skuid){  var $ = skuid.$;  $(document.body).one('pageload',function(){                 var checkboxes = $("#myFieldEditor :input[type=checkbox]");                                  for(var i=0, n=checkboxes.length;i<n;i++) {                     checkboxes[i].checked = true;                 }  }); })(skuid); 
    Are you just wanting them checked in the UI (i.e. no model updates)? As soon as a user tries to edit the fields, the boxes get checked/unchecked according to whatever the value for that field is in the row, right? If you want the values in the rows set to "true" by default, you'll need to use updateRow instead:
    (function(skuid){  var $ = skuid.$;    $(document.body).one('pageload',function(){   var myModel = skuid.model.getModel('MyModel'),    checkboxFields = {};      //  Each through the model fields, and grab the Checkbox fields that are editable   $.each(myModel.fieldsMap,function(){    if (this.displaytype === "BOOLEAN" && this.editable === true) checkboxFields[this.id] = true;   });      //  Set the editable checkbox fields to "true"   $.each(myModel.getRows(),function() {    myModel.updateRow(this,checkboxFields);   });  }); })(skuid); 
    Using updateRow also addresses any permissions issues which might lead users to think that they've checked a box and updated the record when they actually haven't.
  • Pat VachonPat Vachon Member ✭✭
    edited January 2016
    No dice on either function. The checkbox fields are True by default in the object. It's just that this is an issue dislaying them. Forget if it's SF or Skuid issue. Pretty sure it's SF.
  • J.J. Skuad ✭✭
    edited December 2016
    Hmmmm. I did see one thing that needed to change in the first script I posted:
    var checkboxes = $("#myFieldEditor :input[type=checkbox]");
    ...should be...
    var checkboxes = $("#reportoptions :input[type=checkbox]");
    You probably caught it, but I thought I would post this, just in case. Could you grant login access and send the Org ID to [email protected] so I can take a closer look?
  • Pat VachonPat Vachon Member ✭✭
    edited January 2016
    Nope. Didn't catch and now it works. Thanks!!
  • J.J. Skuad ✭✭
    edited December 2016
    Sure thing! I'll have a look at our Page Include code to see if we could do anything different to make this unnecessary, but for now, I'm glad we were able to find a workaround for you.
Sign In or Register to comment.