Repeat region on jQuery BlockUI script fails to work [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 开发者_如何转开发years ago.
Improve this questionI am trying to use repeat region on the jQuery BlockUI script but it fails to work.
This is the code I am using now:
<?php do { ?>
<script type="text/javascript">
$(document).ready(function() {
$('#t<?php echo $row_dd31['dNo']; ?>').click(function() {
$.blockUI({ message: $('#q<?php echo $row_dd31['dNo']; ?>'), css: { width: '1024px' } });
});
$('#yes').click(function() {
// update the block message
$.blockUI({ message: "<h1>Remote call in progress...</h1>" });
$.ajax({
url: 'wait.php',
cache: false,
complete: function() {
// unblock when remote call returns
$.unblockUI();
}
});
});
$('#no').click(function() {
$.unblockUI();
return false;
});
});
</script>
<?php } while ($row_dd31 = mysql_fetch_assoc($dd31)); ?>
Why does it not work?
Can one not use PHP repeat region alongside JavaScript? If not are there any alternatives to be used?
This is the code for the modal dialog:
<!-- modal -->
<?php do { ?>
<div id="q<?php echo $row_dd31['dNo']; ?>" style="display:none; cursor: default">
<h3>Driver <?php echo $row_dd31['dNo']; ?></h3><p>
<input type="button" id="yes" value="Save" style="width: 75px; height: 50px;"/> <input type="button" id="no" value="Exit" style="width: 75px; height: 50px;"/>
</div>
<?php } while ($row_dd31 = mysql_fetch_assoc($dd31)); ?>
This is how the tiles are generated:
<tr height="100px" align="center">
<?php do { ?>
<td style="background-color: <?php echo $row_dd1['colour']; ?>;">
<input type="hidden" id="<?php echo $row_dd1['dNo']; ?>">
<button type="submit" class="link" id="t<?php echo $row_dd1['dNo']; ?>"><span><?php echo $row_dd1['dNo']; ?></span></button>
</td>
<?php } while ($row_dd1 = mysql_fetch_assoc($dd1)); ?>
</tr>
I think the problem is that you are trying to generate jQuery to suit each custom row id, this works in theory however I would say that it is pretty bad application design. I would suggest writing a simple script that can handle all of your rows at once eg.
<div class="my-row-to-bind-jquery-to" id="xyz">...</div>
<div class="my-row-to-bind-jquery-to" id="xyz1">...</div>
<div class="my-row-to-bind-jquery-to" id="xyz2">...</div>
<div class="my-row-to-bind-jquery-to" id="xyz3">...</div>
then you can simply bind the blocking and unblocking of the ui to the class rather than each individual id like below
$(document).ready(function() {
$('.my-row-to-bind-jquery-to').click(function() {
var id = this.id;
// do the rest of your stuff here
});
});
Ok would you able to elaborate on what the
$.blockUI({ message: **$('#parent-row-container')** ...
is supposed to be?
Also, are you getting any errors in your javascript console?
精彩评论