公开元素(使用jquery工具)

时间:2009-12-22 16:53:21

标签: jquery

在按钮的onClick事件上,我正在尝试使用Jquery工具Expose(http://flowplayer.org/tools/expose.html)公开表单(登录表单),但它似乎没有工作..

 

// execute your scripts when the DOM is ready. this is a good habit
$(function() {

    var api1 = $("#login-area").expose({api:true, lazy:true, color: '#78c'});

});
 

这是我试图曝光的部分

<div id="login-area"> 
   <div class="ttl-area"> 
      <h2 class="ttl-login"><span>Login</span></h2> 
   </div> 
   <!-- start login-area --> 
   <div class="login-area"> 
      <div class="login-holder"> 

         <form Id="loginForm" action="/raceday/Account/Login" method="post"> 
            <fieldset> 
               <label for="UserName" id="UserName_Label">Email:</label><input id="UserName" name="UserName" type="text" value="" /> 
               <label for="LoginPassword" id="LoginPassword_Label">Password:</label><input id="LoginPassword" name="LoginPassword" type="password" value="" /> 
               <div class="row"> 
                  <a href="/raceday/Account/ForgotPassword">Forgot your password?</a> 
               </div><br /> 
               <input class="lock btn" id="Login" name="Login" type="submit" value="Login" /> 
            </fieldset> 
         </form> 
      </div> 

      <strong class="ttl">New user to RacedayWorld.com? Signup below:</strong> 
      <form action="/raceday/Account/Edit" method="get"> 
         <input class="new btn" id="New_User" name="New_User" type="submit" value="New User" /> 
      </form> 
   </div> 
</div>

这是对Expose元素的调用

<input type="button" class="register btn" onclick="api1.load()" value="Sign up for this Event" /> 

2 个答案:

答案 0 :(得分:1)

您忘了拨打load()功能。

$(function(){

   // note: modify ".login-area" with any element that you want to expose
   var $api1 = $(".login-area").expose({api:true, lazy:true, color: '#78c'});

   // note: modify ".register" with any element that user will click to expose form
   $(".register").click(function(){
      $api1.load()
   });
});

答案 1 :(得分:0)

确保:

  • 您包含jquery.js
  • 您包含expose.js
  • 该颜色不应该具有真正的十六进制:(又名#78C78C而不是#78C)

另外,不要使用内联javascript,而是在主进程中指定onclick。

因此,请为您的输入提供唯一ID:

<input type="button" id="exposeButton" class="register btn" onclick="api1.load()" value="Sign up for this Event" />

$(function(){
var api1 = $("#login-area").expose({api:true, lazy:true, color: '#78c'});
     $('#exposeButton').bind('click',function(){
         api.load();
     });
});