Skip to content

Commit

Permalink
added auto-selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Allen committed Nov 10, 2009
1 parent 65a6498 commit af819d5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lowpro.jquery.js
Expand Up @@ -101,6 +101,13 @@
}
});

var parseAutoSelectors = function(behavior) {
behavior.elements = {};
for (var key in behavior.options.elements) {
behavior.elements[key] = $(behavior.options.elements[key], behavior.element);
}
}

var bindEvents = function(instance) {
for (var member in instance) {
if (member.match(/^on(.+)/) && typeof instance[member] == 'function') {
Expand All @@ -119,6 +126,7 @@
}
$.extend(this.options, (args && args.length != 0 && typeof(args[0]) == "object")?args[0]:{});

parseAutoSelectors(this);
if ($super) $super.apply(this, args);
},
dispatchEvent: function() {
Expand Down
29 changes: 29 additions & 0 deletions test/auto-selectors.html
@@ -0,0 +1,29 @@
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="../src/lowpro.jquery.js"></script>
<script type="text/javascript">
$.ux.behavior("TestAutoSelectors", {
initialize: function() {
console.log(this.options);
console.log(this.elements);
}
}, {
elements: {
'text': 'span',
'text2': 'div.woot'
}
})
$(function() {
$("#Content").attachAndReturnFirst("TestAutoSelectors");
});
</script>
</head>
<body>
<div id="Content">
<span>Text</span>
<div class="woot">Text 2</div>
</div>
</body>
</html>

0 comments on commit af819d5

Please sign in to comment.