Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-5-s committed Apr 10, 2012
1 parent 56427dd commit a9aa5ca
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ Gets all the search fields and renders a search form
** latitude
** longitude
** radius (miles)
* search_results_page (String) A url (relative) for the search form to send requests
Important to note that the search will be sent to the search results page as a get
request with the parameters store in the url hash - #mls-search:key=value&key2=value
your search_results_page should call [queryAndRenderProperties](queryAndRenderProperties)
on document ready and pass in the hash.
* success (Function) A callback function that fires on success

```javascript
Expand All @@ -175,7 +180,8 @@ $('body').MLSjs({
latitude: 33.73974000503961,
longitude: -84.35771976249998,
radius: 30
}
},
search_results_page: '',
success: function(fields) {
//manually create your search form from the fields

Expand Down Expand Up @@ -217,7 +223,7 @@ Calls the queryProperties function but also renders the properties to the page.
several options for a default template, or you may use your own template

####Parameters
* query
* query (paramters below or url hash (see [renderSearchForm](#renderSearchForm))
** limit (Number)
** image_type: ('horizontal','vertical','square') - return just properties with those image types
** private (true,false) - true will only search from your properties, false is the entire set
Expand Down Expand Up @@ -265,6 +271,23 @@ $("body").MLSjs({
}
}
});

//or use the hash
$("body").MLSjs({
account_id: '1001',
method: 'queryAndRenderProperties',
parameters: {
query: window.location.hash,
template: 'properties',
locals: {
property_page: '/property'
},
success: function(properties) {
console.log(this)
}
}
});

```


Expand Down
21 changes: 15 additions & 6 deletions mlsjs.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
}

return parameters;
}
};

/**
* Fetch the property from the server
Expand Down Expand Up @@ -512,13 +512,20 @@
* Queries properties
* @param {Object} params (mongodb like query params)
* @param {Function} callback(properties) - Array
* @TODO refactor params
* @function
*/
this.queryProperties = function ( params, fn ) {
var account_id = this.options.account_id,
fields = {};
$.getJSON( this.url+'/query/'+account_id + '?callback=?', params ,function( data ){

//What i am doing here:
//I have certain field id's such as city_id,
//state_id and i want to get the full
//state and city objects from those id's
//when i query the db.

//populate the city object if it exists
if (params.city_id) {
var city = $(data.fields.cities).filter(function(k,v){
Expand Down Expand Up @@ -583,10 +590,13 @@
};

/**
* This function will preload fields from drop downs and radios
* @param {Object} fields The collection of all fields and all field
* This function will preload fields from drop downs and radios.
* This is a static method that is used to add a `selected` property
* to the `field` object in a collection of `fields`
* @param {Object} fields The collection of all fields and all values in that field
* values for each field
* @param {Object} preloaded_fields the id's of the fields to mark as selected
* @TODO currently only supports cities and states
*/
this.preloadFields = function( fields, preloaded_fields) {

Expand All @@ -613,9 +623,8 @@
}
}

return fields;

}
return fields;
};


/**
Expand Down

0 comments on commit a9aa5ca

Please sign in to comment.