Skip navigation
ion
Currently Being Moderated

execute js function on clicking tab?

Jan 31, 2012 8:45 AM

i have a js function that works fine when attached to the onClick event of a button, but i want it to execute when user clicks the tab

 

is there a way to do that?

 

function clearURL() {

var testURL = document.URL;

var urlQry = testURL.split("?")[1];

if (urlQry != "")

    {

    var activeTab = ColdFusion.Layout.getTabLayout('myLayout').getActiveTab().title;

    if (activeTab == 'myTabTitle')

        {

        var newURL = testURL.split("?")[0];

        window.location = newURL;

        }

    }

}

 

thanks

 
Replies
  • Currently Being Moderated
    Jan 31, 2012 11:37 AM   in reply to ion

    <div onclick="clearURL()">

    <cflayout>

    </cflayout>

    </div>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 1, 2012 12:23 PM   in reply to ion

    ion wrote:

     

    thanks BKBK, but is not really working. is not the whole layout that needs to be affected, only one layoutarea.

    when i do this, it throws the layout out of wack, and when clicked, it does nothing (no error either)

     

    I understand. You could place the DIV within the layoutarea, as in this example:

     

    <script type="text/javascript">

    f = function () {

        alert('Karamba!')

    }

    </script>

    <cflayout type="tab" name="tabLayout">

        <cflayoutarea name="tab1" title="Tab 1">

           Tab 1 contents

        </cflayoutarea>

         <cflayoutarea name="tab2" title="Tab 2">

               <div  onclick="f()" >

           Tab 2 contents

        </div>

        </cflayoutarea>     

    </cflayout>

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 4:45 PM   in reply to ion

    I used this to submit a form using ajax whenever a new tab is selected.  This is essentially the onclick portion:
    ColdFusion.Layout.onTabActivate = function(tab)

     

    <script type="text/javascript">
    ColdFusion.Layout.onTabActivate = function(tab){
          ColdFusion.Ajax.submitForm('myform', 'my.cfm')
      }
      </script>

        <cfform id="myform" name="myform" action="my.cfm" method="post">
      <cflayout type="tab" name="tabLayout">
          <cflayoutarea name="tab1" title="Tab 1">
            Tab 1 contents (form input)
          </cflayoutarea>
          <cflayoutarea name="tab2" title="Tab 2">
            Tab 2 contents (form input) 
        </cflayoutarea> 
      </cflayout>
      </form> 

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 5:30 PM   in reply to ion

    Maybe this will help: http://api.jquery.com/keypress/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points