Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Associating SmartClient object with pre-defined DOM element

    This is probably a dumb question, but it's not obvious to me from the documentation whether this is possible.

    What I have is a barebones HTML page, which defines a series of DIVs that I want to fill with objects that SmartClient helps me create (e.g., ListGrid, etc) as the JavaScript on my page executes (e.g., body onload). Can I do this? If I cannot, how can I position the SmartClient object relative to the object or is that just impossible?

    Thank you.

    #2
    Hi,

    I got the same problem and I apply a dirty hack to get around this problem.
    I draw the objects inside the body and afterwards move them around. I use jquery for this, here an example:

    // Search <body>-tag for <div id="isc_xxx"..>-tag and move those tags to div having class="gtb_tabContent"

    var tabContentDiv=$(".gtb_tabContent");
    $("body > div").each(function() {
    if($(this).attr("id").indexOf("isc_")==0) {
    tabContentDiv.append(this);
    }
    });

    Comment


      #3
      You will find it far easier to use the SC layout objects to build your bare-bones layout. Otherwise look at Basics->HTML->Inline components in the feature explorer.

      Comment


        #4
        Thanx davidj6,

        I looked at the example on inline components: http://www.smartclient.com/docs/7.0r...ine.Components
        and tried to do the same.
        I got a <div>-tag with position:relative and I add the components with position:absolute to it, like:
        <div id="foobar" style="position:relative;">
        <script>
        ...
        ListGrid.create({
        ...
        position: "absolute",
        top:0, left: 180,
        ...
        ...
        </script>
        </div>

        But when I add the components to the div, smartclient makes some calculation and sets top and left to negative values.
        So now I add the components with position:relative (the smartclient leaves top and left values alone) and afterwards I set the position to "absolute" manually, like:
        var foobarDiv=$("#foobar");
        $("> div",foobarDiv).each(function() {
        if($(this).attr("id").indexOf("isc_")==0) {
        $(this).css({position:"absolute"});
        }
        });

        A bit ugly. I don't know why smartclient changes the top and left values, when a new component's position is absolute.

        Comment


          #5
          I'm slowly getting closer to "clean" code. Now I add a canvas with position:"relative" to the div and later I add the components to that canvas using parentElement:contentCanvas. Now I can use position: "absolute" in the components and smartclient does not change top and left any more.

          Conclusion:
          if you add components having position:absolute to a <div style="position:relative"> then smartclient changes top and left, even though the containing div says position:relative. If you add components to other components then smartclient does not touch top and left.
          Last edited by rudirakete; 26 Jul 2010, 23:48.

          Comment

          Working...
          X