我现在自己写一个类似google分页的控件,碰到一个问题,大体描述如下:
function _Page(container) {
//总条数
this.total_records = 0;
//每页显示多少条
this.page_size = 5;
//现在的页码数
this.cur_page = 1;
//导航条一共显示多少页的导航
this.page_num_show = 5;
this.container = container;
this.SetPageInfo('1');
}
_Page.prototype.SetPageInfo = function(curPage)
{
......一段计算代码
然后输出页码,这里需要调用SetPageInfo这个方法,但是进去所有属性都不在了
out += '<a href="javascript:_Page.prototype.SetPageInfo(\'' + i + '\',' + pageObject + ')">' + i + '</a> ';
}我界面上上new _Page();一个对象,导致点击页码出错。请问应该如何解决这个问题
function _Page(container) {
//总条数
this.total_records = 0;
//每页显示多少条
this.page_size = 5;
//现在的页码数
this.cur_page = 1;
//导航条一共显示多少页的导航
this.page_num_show = 5;
this.container = container;
this.SetPageInfo('1');
}
_Page.prototype.SetPageInfo = function(curPage)
{
......一段计算代码
然后输出页码,这里需要调用SetPageInfo这个方法,但是进去所有属性都不在了
out += '<a href="javascript:_Page.prototype.SetPageInfo(\'' + i + '\',' + pageObject + ')">' + i + '</a> ';
}我界面上上new _Page();一个对象,导致点击页码出错。请问应该如何解决这个问题
function a(container) {
this.b = 0;
this.cont = container;
}
a.prototype = {
c:function(n) {
var out = '<a href="javascript:void(0)" id="link">this.b</a>';
this.container.innerHTML = out;
out = document.getElementById('link');
var self = this;
out.onclick = function() {self.c(n)};
}
}