-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Where to find "opener" object ant its attributes? #32
Comments
@sashabeep I will going to do implement this change asap. |
$('.buildform').unbind('click.lightcase').bind('click', function (event) {
event.preventDefault();
var arr={
index:$(this).data("index")
}
});
....
$('.buildform').lightcase({
onInit : {
foo: function() {
console.log(arr['index']);
}
}, no glue
|
Sorry Sascha, wrote it in the wrong way. Following binding would be correct:
|
But anyway, you wouldn't be able to access the variable |
Yep, still no effect $('.buildform').lightcase({
showSequenceInfo : false,
type: 'ajax',
ajax : {
width : 'auto',
height : 'auto',
type : 'post',
dataType : 'html',
//in this case only first link data-attributes will be translated to builder and i get one form in all cases
data:{index:$('.buildform').data("index"), idform:$('.buildform').data("idform"), token:$('.buildform').data("token"), formzag:$('.buildform').data("formzag"), formbut:$('.buildform').data("formbut"), addtext:$('.buildform').data("addtext")}
}, and then i init this form... onFinish : {
initializeForm : function () { of course, if i change it to GET it will be ok but i need to urlencode non-latin characters Colorbox implementation was $(".buildform").on("click",function(event){
event.preventDefault();
var index = $(this).data("index");
var idform = $(this).data("idform");
var token = $(this).data("token");
var formzag = $(this).data("formzag");
var formbut = $(this).data("formbut");
var addtext = $(this).data("addtext");
$.colorbox({
open: true,
scrolling: false,
innerWidth:'500',
href:"form.php",
data:{index:index,idform:idform,token:token,formzag:formzag,formbut:formbut,addtext:addtext},
onClosed:function(){
//Do something on close.
}, |
You can use: But probably would get to |
TypeError: lightcase.objectData is undefined |
Hmm, of course!
|
still undefined with http://cornel.bopp-art.com/lightcase/lightcase/lightcase.js |
hmm, but then if you use just |
I'm not sure i understand... Nothing changed, when i tried this in init. so i comment this |
|
No. still TypeError: lightcase.objectData is undefined
|
Uncaught TypeError: Cannot read property 'origin' of undefined |
Reason was that |
TypeError: lightcase.origin is undefined |
TypeError: lightcase.origin is undefined |
I have set |
Nothing changed, still undefined |
You can see how it works on http://cake52.ru/ - last two links in the footer at the end of page with envelope and question sign icons |
Hmm, you are out of the plugin context where you want to access this data. This is basically not possible. With this previous changes, you should be able now to access object data from within a hook. onInit: {
setAjaxRequestData: function () {
lightcase.settings.ajax.data = {index: $(this).data('index')};
}
},
... |
Or alternatively, you are going to do it the same way as while using colorbox and creating your own click event handler around and calling $('.buildform').on('click', function (event) {
event.preventDefault();
var options = {
// Put all your settings here
ajax: {
...,
data: {index: $(this).data('index'),...}
}
};
$(this).lightcase('start', options);
}); |
I think populating of those variables with onInit will be more readable, now it works as expected (imho). You should describe this case in help section. Performing POST request to modal window using link or button is not so frequently case, but, who knows, maybe someone will do similar trick. Thank you very much for help |
I will optimize this change a bit and will document |
How to implement all of this in the current release? |
Thanks for sharing the link. Much better to analize now. |
Opening a blank window: <a href="#" data-rel="lightcase">Blank popup</a> or without a DOM element lightcase.start({'href':'#', 'more': 'options', 'come': 'here'}); After fill in with content, you would need to reset lightcase dimensions like this: lightcase.resize(); |
Should do the trick now even when using $(this): $('.buildform').lightcase({
onStart: {
setAjaxRequestData: function () {
lightcase.settings.ajax.data = {
index: $(this).data('index'),
idform: $(this).data('idform'),
token: $(this).data('token'),
formzag: $(this).data('formzag'),
formbut: $(this).data('formbut'),
addtext: $(this).data('addtext')
};
}
}
}); |
Maybe, i miss something. lightcase.settings.ajax.data filled but no parameters sent. $('.buildform').lightcase({
onStart: {
setAjaxRequestData: function () {
lightcase.settings.ajax.data = {
index: $(this).data('index'),
idform: $(this).data('idform'),
token: $(this).data('token'),
formzag: $(this).data('formzag'),
formbut: $(this).data('formbut'),
addtext: $(this).data('addtext')};
console.dir(lightcase.settings.ajax.data);
}
},
showSequenceInfo : false,
type: 'ajax',
ajax : {
width : 'auto',
height : 'auto',
type : 'post',
dataType : 'html'}
}); check on link in section 1 http://ok.rfw.su/start/ |
You can't do this you are in an object declaration: console.dir(lightcase.settings.ajax.data); do this call outside, but still within the setAjaxRequestData() function. |
Never feel myself so stupid, i can't understand myfunction(){
lightcase...?.open();
$.ajax({
type: "POST",
url: '/order.html',
data: ({mydata:...}),
dataType: "html",
success: function(data) {
fill_Ligthcase_With(data);
}
});
lightcase.resize();
} |
lightcase.get('contentInner').html(myContent);
lightcase.resize(); |
Tried with $('.buildform').on('click', function (event) {
event.preventDefault();
var index = $(this).data("index");
var idform = $(this).data("idform");
var token = $(this).data("token");
var formzag = $(this).data("formzag");
var formbut = $(this).data("formbut");
var addtext = $(this).data("addtext");
lightcase.start({'href':'#'});
$.ajax({
type: "POST",
url: '/form.php',
data: ({index:index,idform:idform,token:token,formzag:formzag,formbut:formbut,addtext:addtext}),
dataType: "html",
success: function(data) {
lightcase.get('contentInner').html(data);
//lightcase.resize();
}
});
}); Magic! |
Seen response in console - it's corect html structure with all needed elements to display in lightcase window |
You can try to click this link |
and does this work? $(‘#lightcase-contentInner’).html(…);
|
Strange that i can remove this layer, but can't update |
same with |
are you in the right hook?
|
resize cause lightcase to be blank check it on the same page |
try: lightcase.get('contentInner').children().append($(data)); |
Looks like padding is back but content is cropped, resize not working - all the block is white |
.lightcase-contentInner opacity 0 after lightcase.resize(); |
and many many many many errors "blank string cannot be argument of method getElementById()" when opening. Only for this window |
Sorry, but i have no problems getting it working. lightcase.start({
'href': '#',
onFinish: {
fillLightcaseWithContent: function () {
lightcase.get('contentInner').children().html('<div>abc</div>');
lightcase.resize();
}
}
}); |
Tried to writie response to hidden layer and then display - errors gone $('.buildform').on('click', function (event) {
event.preventDefault();
var index = $(this).data("index");
var idform = $(this).data("idform");
var token = $(this).data("token");
var formzag = $(this).data("formzag");
var formbut = $(this).data("formbut");
var addtext = $(this).data("addtext");
$.ajax({
type: "POST",
url: '/form.php',
data: ({index:index,idform:idform,token:token,formzag:formzag,formbut:formbut,addtext:addtext}),
dataType: "html",
success: function(data) {
var response = data;
$('body').append('<div id="response" style="display:none">');
$("#response").html(data);
}
});
lightcase.start({
href:'#response',
width:550,
height:'auto',
onFinish : {
baz: function() {
lightcase.resize();
}
}
});
}); only width is not set but it doesn't matter |
well, it also should work without a such layer. what browser? width and height are no settings.
|
firefox |
Can I close this issue? I also have tested to open a blank popup and works with two different approaches: on the fly, or with a DOM helper object. |
OK, sure, but, i think, without examples this section of help is useless |
Ok, true! I added an example. |
.....
I can't store, for example, data-attributes to array using onclick event, because lightcase unbind this
The text was updated successfully, but these errors were encountered: