[jQuery] Re: Iframe - adding and removing hidden form elements

2009-09-15 Thread Benster-


OK got the delete working, here is the final function:

$(document).ready(function(){
 $(':checkbox.addPhoto').click(function(){
if ($(this).attr('checked')) {
// Add element to form
$("#post", 
parent.document.body).append("");
} else {
// Delete element from form
$("#post input[id='" + 
$(this).attr('id') + "']",
parent.document.body).remove();
}
});
});

-- 
View this message in context: 
http://www.nabble.com/Iframe---adding-and-removing-hidden-form-elements-tp25343500s27240p25450789.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Iframe - adding and removing hidden form elements

2009-09-08 Thread Benster

Hi,

I have a page that opens up an iframe for the user to be able to
select photos.  Each photo has a checkbox, and on select I add a
hidden form element to the parent frame form.  This all seems to work
fine, but im now stuck on how to remove the form element when the
checkbox is un-checked.

Heres what I have:

$(document).ready(function(){

 $(':checkbox.addPhoto').click(function(){
if ($(this).attr('checked')) {
// Add element to form
$("#post", parent.document.body).append("");
} else {
// Delete element from form
$("#post", parent.document.body).remove("");
}
});

});


Using "Append" works great for adding, however im not sure how to go
about the removal.  Above I am trying to use "remove" but this fails.

Can anyone advise on how I would delete a string from a form on the
parent frame?

Best regards, Ben.


[jQuery] Re: Context Menu plugin - id of clicked element

2008-03-04 Thread Benster

Hi Dan,

Many thanks for the reply, thats been a great help.  Finally got it
working!

Heres some sample code for anyone else interested.

Regards, Ben.


$(document).ready(function() {

 $('span.demo1').contextMenu('myMenu1', {
  bindings: {
'1': function (trigger, target){
  alert('Trigger was '+t.id+'\nAction was Open');
},
'2': function(t) {
  alert('Trigger was '+t.id+'\nAction was Email');
},
'3': function(t) {
  alert('Trigger was '+t.id+'\nAction was Save');
},
'4': function(t) {
  alert('Trigger was '+t.id+'\nAction was Delete');
}
  }
});

});




  
Test 1
Test 2
Test 3
Test 4
  


 RIGHT CLICK FOR DEMO

THIS WORKS TOO

THIS WORKS TOO
THIS WORKS TOO
THIS WORKS TOO
THIS WORKS TOO
THIS WORKS TOO


On Mar 3, 2:55 pm, "Dan G. Switzer, II" <[EMAIL PROTECTED]>
wrote:
> Benster,
>
>
>
> >Im new to jquery and im struggling with hopefully a simple question!
>
> >Im using theContextMenuplugin-
> >http://www.trendskitchens.co.nz/jquery/contextmenu/
> >which allows you to generate a right-clickmenu.  All works fine,
> >however im now trying to pass in the id of the item that has been
> >clicked upon.
>
> >Im listing several images on a page, and offering the right-clickmenu
> >for each.  I need to pass in the id of the image which has been
> >clicked.  Each image has a div with a unique id.
>
> >The documentation mentions "bindings" which i think is what im after,
> >but have no idea how to display the function pairs.  Here is the
> >description from the docs -
>
> >An object containing "id":function pairs. The supplied function is the
> >action to be performed when the associated item is clicked. The
> >element that triggered the currentmenuis passed to this handler as
> >the first parameter.
>
> >Can anyone advise me on how to proceed?
>
> It's been a while since I've used that plug-in for a project, but it is the
> "bindings" option you're looking for:
>
> $("#attachTo").contextMenu("#menuDiv", {
> bindings : {
> "a.cm_item" : function (trigger, target){
> // "trigger" is the "#attachTo" element
> console.log(trigger);
> // "target" should be the "a.cm_item" element
> console.log(target);
> }
> }
>
> });
>
> The above should attach a click event to every  tag
> found in thecontextmenu. The "target" argument should be a reference to
> this DOM element.
>
> -Dan


[jQuery] Context Menu plugin - id of clicked element

2008-03-02 Thread Benster

Hi,

Im new to jquery and im struggling with hopefully a simple question!

Im using the Context Menu plugin - 
http://www.trendskitchens.co.nz/jquery/contextmenu/
which allows you to generate a right-click menu.  All works fine,
however im now trying to pass in the id of the item that has been
clicked upon.

Im listing several images on a page, and offering the right-click menu
for each.  I need to pass in the id of the image which has been
clicked.  Each image has a div with a unique id.

The documentation mentions "bindings" which i think is what im after,
but have no idea how to display the function pairs.  Here is the
description from the docs -

An object containing "id":function pairs. The supplied function is the
action to be performed when the associated item is clicked. The
element that triggered the current menu is passed to this handler as
the first parameter.

Can anyone advise me on how to proceed?

Best regards, Ben.