Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

and anywhere where you needed $('#photos') you'd use:

$element

you could also add some defaults thus:

 var defaults = {
 perpage : 5,
 currentPage : 1
 }

and even override them:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit",
 perpage:6
 });
});

(削除) You could then inject your css inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also (obviously) be a dependency.

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

and anywhere where you needed $('#photos') you'd use:

$element

you could also add some defaults thus:

 var defaults = {
 perpage : 5,
 currentPage : 1
 }

and even override them:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit",
 perpage:6
 });
});

(削除) You could then inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also (obviously) be a dependency.

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

and anywhere where you needed $('#photos') you'd use:

$element

you could also add some defaults thus:

 var defaults = {
 perpage : 5,
 currentPage : 1
 }

and even override them:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit",
 perpage:6
 });
});

(削除) You could then inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also (obviously) be a dependency.

added 73 characters in body
Source Link
user31638
user31638

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

and anywhere where you needed $('#photos') you'd use:

$element

you could also add some defaults thus:

 var defaults = {
 perpage : 5,
 currentPage : 1
 }

and even override them:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit",
 perpage:6
 });
});

(削除) You could then inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also (obviously) be a dependency.

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

(削除) You could then inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also be a dependency.

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

and anywhere where you needed $('#photos') you'd use:

$element

you could also add some defaults thus:

 var defaults = {
 perpage : 5,
 currentPage : 1
 }

and even override them:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit",
 perpage:6
 });
});

(削除) You could then inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also (obviously) be a dependency.

Source Link
user31638
user31638

I would wrap your jquery as a plugin. Here's a boilerplate to help you refactor this.

You could then call your function as $('#photos').myInfinteScroll();

Anywhere you want to access dynamic controls I would then inject these into the plugin as options, so something like:

$(document).ready(function() {
 $('#photos').myInfinteScroll({
 searchTerm:"#search",
 submitClick:"#submit"
 });
});

Allowing you to access these elements inside your plugin thus:

var searchTerm = $(plugin.settings.searchTerm).val();

(削除) You could then inject your css so this would make your entire function callabled from inside the plugin and allow you to move it/use it on any elements you wish. (削除ここまで)

Forget that, just add the css as a dependency, also Jquery would also be a dependency.

default

AltStyle によって変換されたページ (->オリジナル) /