javascript - submit button doesnt read the jquery script after submitting the first form -
i have main page name vertical menu. when click 1 of menu search loads form dynamically on content.
here first form.
<?php echo validation_errors(); ?> <?php $attr = array( 'class' => 'search_user' ); echo form_open('controller/function', $attr); ?> <p>username or email: <input type="text" name="user_mail" size="30"/> </p> <p> within: <select name="by_search" id="select"> <option value="reg" <?php echo set_select('by_search','reg'); ?> > registered </option> <option value="non_reg" <?php echo set_select('by_search','non_reg'); ?> > non registered </option> </select> </p> <p> <input type="submit" name="submit" id="submit" value="submit search" /></p> <!-- end .content --></div> <!-- end .container </div> --> </form> <script type="text/javascript" src="<?php echo base_url(); ?>js/content.js"></script>
after submitting form displays form;
<div class="content"> <?php echo validation_errors(); ?> <?php $attributes = array( 'class' => 'registered' ); echo form_open('controller/function',); ?> <h2>user management panel</h2> <p>username or email: <input type="text" name="user_mail" size="30"/> </p> <p> within: <select name="by_search" id="select"> <option value="reg" <?php echo set_select('by_search','reg'); ?> > registered </option> <option value="non_reg" <?php echo set_select('by_search','non_reg'); ?> > non registered </option> </select> </p> <p><input type="submit" name="button" id="button" value="submit search" /></p> <table width="630px" style=" margin-left:10px" cellspacing="2" cellpadding="2" border="1" align="center" > <tr bgcolor="#cccccc" > <td width="40px" align="center" ><font face="arial, helvetica, sans-serif">id</font></td> <td width="80px" ><font face="arial, helvetica, sans-serif"> username</font></td> <td width="80px" ><font face="arial, helvetica, sans-serif"> first name</font></td> <td width="80px" ><font face="arial, helvetica, sans-serif">last name</font></td> <td width="80px" ><font face="arial, helvetica, sans-serif">status</font></td> </tr> <?php foreach($query $row){ ?> <tr> <td align="center" ><font face="arial, helvetica, sans-serif"><?php print $row->id; ?></font></td> <td ><font face="arial, helvetica, sans-serif"><?php echo "<a href= 'user_manage/user/$row->username';" ?>><?php print $row->username; ?> </a> </font></td> <td ><font face="arial, helvetica, sans-serif"><?php print $row ->firstname; ?></font></td> <td ><font face="arial, helvetica, sans-serif"><?php print $row ->lastname; ?></font></td> <td ><font face="arial, helvetica, sans-serif"><?php print $row ->status; ?></font></td> <?php }?> </tr> </table> <!-- end .content --></div> <!-- end .container </div> --> </form> <script type="text/javascript" src="<?php echo base_url(); ?>js/content.js"></script>
this content.js
$('a.webwidget_vertical_menu').click(function(){ var linkme = $(this); var url = linkme.attr("href"); $(".content").load(url); homecoming false; }); $(".search_user").submit(function(){ //alert("capture test"); var frm = $(".search_user"); $.ajax({ type: frm.attr("method"), url: frm.attr("action"), data: frm.serialize(), success: function(data){ $(".content").html(data); }, error:function(xhr,err){ alert("readystate: " +xhr.readystate + "\nstatus: " +xhr.status); alert("responsetext: "+ xhr.responsetext); } }); homecoming false; }); $(".registered").submit(function(){ //alert("capture test"); var frm = $(".registered"); $.ajax({ type: frm.attr("method"), url: frm.attr("action"), data: frm.serialize(), success: function(data){ $(".content").html(data); }, error:function(xhr,err){ alert("readystate: " +xhr.readystate + "\nstatus: " +xhr.status); alert("responsetext: "+ xhr.responsetext); } }); homecoming false; });
it seems .registered submit not reading or working because tried alert doesn't go there. when click submit on sec form content has been displayed other elements of page disappear.my objective create content dynamic. new jquery find useful don't know how implement correctly on events. in advanced.
remove .js
in sec page
try below code
$('.registered').delegate('click', function(){ $('.registered').submit(); });
or
$('.registered').delegate('submit', function(){ //your code });
javascript jquery codeigniter
No comments:
Post a Comment