Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-02-2009, 02:18 PM   PM User | #1
kaisellgren
Regular Coder

 
Join Date: Jan 2006
Location: Finland, Hollola
Posts: 285
Thanks: 8
Thanked 0 Times in 0 Posts
kaisellgren is an unknown quantity at this point
None of jQuery UI functions work when called inside of a JS object?

Hi,

I am using objects in JS and I am trying to add draggable() into a DIV that works when I move the function out of the object context.

Example:
Code:
function obj_xxx() {
 this.init = function() {
  $(function() { $("#test").draggable();
 }
}

testobj = new obj_xxx();
testobj.init();
That does not work. However, if I do this:

Code:
testobj = new obj_xxx();
testobj.init();
$(function() { $("#test").draggable();
Then it will work... because the draggable() function is not within the object.

I need this to work within the object, because I will have several DIVs associated with objects and I need them to have draggable() in specific cases.

Help?
__________________
PHP 5 & MySQL 5 (Y)
kaisellgren is offline   Reply With Quote
Old 04-02-2009, 02:37 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Seems to work fine like this:

Code:
<script type="text/javascript">
function obj_xxx() {
	this.init = function() {
		$("#test").draggable();
	}
}
$(document).ready(function() {
	testobj = new obj_xxx();
	testobj.init();
})
</script>
All in all, it seems you have one too many unnamed functions, plus you don't seem to be closing all parentheses in your version.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 04-02-2009, 02:41 PM   PM User | #3
kaisellgren
Regular Coder

 
Join Date: Jan 2006
Location: Finland, Hollola
Posts: 285
Thanks: 8
Thanked 0 Times in 0 Posts
kaisellgren is an unknown quantity at this point
Oh thanks. It works now... I just removed the function part of it...
__________________
PHP 5 & MySQL 5 (Y)
kaisellgren is offline   Reply With Quote
Old 04-02-2009, 03:03 PM   PM User | #4
kaisellgren
Regular Coder

 
Join Date: Jan 2006
Location: Finland, Hollola
Posts: 285
Thanks: 8
Thanked 0 Times in 0 Posts
kaisellgren is an unknown quantity at this point
Damn I have a new problem...

Code:
$("#test").resizable({resize: function (event, ui) { ... }});
I am calling that inside the object, but it will not work, because again, there is a function that I use as a callback for onresize event. How would I solve this? I can't just drop the word function...
__________________
PHP 5 & MySQL 5 (Y)
kaisellgren is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:23 AM.


Advertisement
Log in to turn off these ads.